gpt4 book ai didi

node.js - 在 Node.JS 中使用 Passport 注册(注册)

转载 作者:太空宇宙 更新时间:2023-11-03 22:38:17 24 4
gpt4 key购买 nike

使用 Passport 本地示例,我可以登录工作。没有关于如何注册用户的文档。

我想为用户提供一个“电子邮件”和“密码”字段,他们可以使用它们来注册该网站。我怎样才能做到这一点?有什么原因没有记录下来吗?这真的很明显吗?

最佳答案

其实这个已经解释了太多次了..如果您使用的表架构是User,那么只需在数据库中创建一条新记录。

var newUser = new User();
newUser({username: req.body.username , password : req.body.password});
newUser.save(function(doc , error){
if(error) console.log('user is not saved');
res.send(200);
})

关于node.js - 在 Node.JS 中使用 Passport 注册(注册),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19555495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com