Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing an array of flash message as info argument #39

Closed
niftylettuce opened this issue Jun 12, 2012 · 1 comment
Closed

Allow passing an array of flash message as info argument #39

niftylettuce opened this issue Jun 12, 2012 · 1 comment

Comments

@niftylettuce
Copy link

Per comment in jaredhanson/passport-local#8.

@jaredhanson
Copy link
Owner

I'm edge-casey on this one. If an app really needs to do this, I'd suggest setting the passReqToCallback option, as so:

passport.use(new LocalStrategy({ passReqToCallback: true }
  function(req, username, password, done) {
    User.findOne({ username: username }, function (err, user) {
      if (err) { return done(err); }
      if (!user) { return done(null, false); }
      if (!user.verifyPassword(password)) {
        req.flash('error', 'Your password is too long');
        req.flash('error, 'Also, it is too short!!!');
        return done(null, false);
      }
      return done(null, user);
    });
  }
));

req becomes the first argument to the verify callback, and you can use it to flash messages to your heart's content.

If enough people +1 this, I'll consider it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants