javascript - Req flash with delay in express 4 app -
i'm using passport js local strategy authenticate user webapp see delay setting flash message , try using {message : ''} option in passport , passing request function setting manually flash message delay persist :
passport.use(new localstrategy({passreqtocallback:true}, (req,username,password,done)=>{ userbl.getuserbyusername(username).then((user) => { if (user != null && user != undefined) { if (password == user.password) { return done(null,user) } else { return done(null,false,req.flash('error','constraseña incorrecta')) } } else { return done(null,false,req.flash('error','usuario')) } }); })); and call error req.flash('error') empty , after second reload or time show's error , flash value , . thanks
it's normal delay req flash or error ?
according documentation http://passportjs.org/docs, should pass like
done(null, false, { message: 'incorrect username.' }); but seems you're handling error message using
return done(null,false,req.flash('error','constraseña incorrecta')) which might cause kind of asynchronous issue think.
Comments
Post a Comment