node.js - Locals/ Helpers Provided By Passport -
i got done replacing everyauth/ mongoose-auth login system passport implementation. i'm using purely local username/ password logins, i'm utilizing passport-local module well.
i know looking through few examples, found passport auto-assigns couple req helpers. i've not been able find full list of variables puts there though, couple i've found req.isauthenticated() , req.user variables.
is there full list provided anywhere online? interested in options available in routes/ views. can keep trolling through examples, nice if there reference somwhere.
for connect/express application,
1.var passport = require('passport');
the following 4 helper functions added http.incomingmessage.prototype(i.e., request object's prototype):
- login/login(user, [options,] done)
- logout/logout()
- isauthenticated() - i.e. whether
req.userexists. - isunauthenticated()
if user authenticated successfully, callback function done(null, user) called. callback function calls req.login() in turn calls serializeuser() store user id req._passport.session.user.
the req.logout() function deletes req._passport.session.user.
2.app.use(passport.initialize());
get passport info current session , store req._passport.session(i.e., req.session['passport']).
3.app.use(passport.session());
check whether req._passport.session.user exists, is, whether user id stored in current session. if yes, call deserializeuser() user object stored req.user.
Comments
Post a Comment