我稍微改进了上述解决方法(不能将其称为解决方案,因为它似乎在everyauth中缺乏功能):
第一部分保持不变:
app.get('/login/facebook', function(req, res) {
req.session.redirect = req.header('referer');
res.redirect('/auth/facebook');
});
第二部分移至everyauth.facebook.findOrCreateUser
:
findOrCreateUser(function(session, accessToken, accessTokenExtra, facebookUser){
var promise = this.Promise();
// your logic of finding or creating the user here
if (session.redirect) { // just before the return
this.redirectPath(session.redirect); // dynamic path
delete session.redirect;
}
return promise;
}).
redirectPath('/'). // static path