【发布时间】:2015-04-23 18:33:06
【问题描述】:
我正在按照本教程在 NodeJS 中编写本地登录代码:
https://scotch.io/tutorials/easy-node-authentication-setup-and-local
在 config/passport.js 文件中
function(req, email, password, done){
process.nextTick(function(){
User.findOne({'local.email' : email}, function(err, user){
if(err)
return done(err);
if (user){
return done(null, false, req.flash('signupMessage', 'message'));
}
我是 NodeJS 和 Javascript 的新手,我不明白像“done”这样的值如何成为函数(返回 done(err))。有系统功能吗?
非常感谢!
【问题讨论】:
-
回调函数。它将结果返回给您传递给它的函数。
-
这只是回调的名称,我说对了吗?
-
是的!这是回调的名字,你可以随意命名
标签: javascript node.js passport.js