I am trying to work my passport local strategy.
I've got this middleware set up:
passport.use (new local credentials (function (username, password, done) {// returned (blank, user ); If (user name == 'ben' & password == 'benny') {console.log ("password is correct"); returned (empty, correct);} returned refund (empty, false , {Message: "wrong login"});}));
But then here in the
app. Usage ('/ admin', adminIsLoggedIn, admin); Function adminIsLoggedIn (req, res, next) {// If the user is authenticated in the session, then continue (req.isAuthenticated ()) back to the next (); // if they do not redirect them to the home page res.redirect ('/'); }
It always fails and redirects to the home page.
I do not understand why this is happening? Why would not it be certified?
In my console, I can see that this password is correct
printing why would not it work?
I had a similar problem. Due to the required express-session middleware for passport, it may have been fixed using the following moderators: (Express 4)
var session = Required ('Express-session') ; // Passport Session is required for app.use (session ({secret: 'secrettexture', saved: updated: true, revert truth, // using store session on MongodiBi using Exchange session: new mongostore ( {Url: config} UrlMongo, archive: 'session'}}})); // Init Passport Authentication App Usage (passport.in initialize ()); // Continuous login session. Usage (Passport Session ());
No comments:
Post a Comment