Passport.js authenticate() custom callback and failureFlash behavior
0 reputation · 10 Aug 2020, 18:47 UTC
Custom Callback Integration
In Passport.js (v0.6.x–v0.7.x), the passport.authenticate() middleware allows for a custom callback to handle the authentication result manually. When utilizing the default middleware behavior, providing failureFlash: true in the options object automatically populates req.flash() with the message returned by the strategy.
Configuration Uncertainty
There is a discrepancy when transitioning to a custom callback. While the options object can still be passed, the automated flash behavior appears to be bypassed. This requires a decision on whether the application should manually extract the message from the info object or if there is a configuration that allows the internal flash logic to execute alongside a custom callback.
- Does the use of a custom callback explicitly override the
failureFlashandsuccessFlashlogic? - Is there a supported way to retain automated flash messaging while maintaining control via a custom callback?