Skip to content

Commit 4c3dbec

Browse files
author
Daniel Harvey
committed
Add documentation for message and flash options
Add documentation to the authenticate() method for options `successMessage`, `successFlash`, `failureMessage` and `failureFlash`. Add documentation for the optional `status` argument of the callback method.
1 parent aa74207 commit 4c3dbec

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/middleware/authenticate.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,31 @@ var http = require('http')
1717
* Options:
1818
* - `session` Save login state in session, defaults to _true_
1919
* - `successRedirect` After successful login, redirect to given URL
20+
* - `successMessage` True to store success message in
21+
* req.session.messages, or a string to use as override
22+
* message for success.
23+
* - `successFlash` True to flash success messages or a string to use as a flash
24+
* message for success (overrides any from the strategy itself).
2025
* - `failureRedirect` After failed login, redirect to given URL
26+
* - `failureMessage` True to store failure message in
27+
* req.session.messages, or a string to use as override
28+
* message for failure.
29+
* - `failureFlash` True to flash failure messages or a string to use as a flash
30+
* message for failures (overrides any from the strategy itself).
2131
* - `assignProperty` Assign the object provided by the verify callback to given property
2232
*
2333
* An optional `callback` can be supplied to allow the application to overrride
2434
* the default manner in which authentication attempts are handled. The
2535
* callback has the following signature, where `user` will be set to the
2636
* authenticated user on a successful authentication attempt, or `false`
2737
* otherwise. An optional `info` argument will be passed, containing additional
28-
* details provided by the strategy's verify callback.
38+
* details provided by the strategy's verify callback - this could be information about
39+
* a successful authentication or a challenge message for a failed authentication.
40+
* An optional `status` argument will be passed when authentication fails - this could
41+
* be a HTTP response code for a remote authentication failure or similar.
2942
*
3043
* app.get('/protected', function(req, res, next) {
31-
* passport.authenticate('local', function(err, user, info) {
44+
* passport.authenticate('local', function(err, user, info, status) {
3245
* if (err) { return next(err) }
3346
* if (!user) { return res.redirect('/signin') }
3447
* res.redirect('/account');

0 commit comments

Comments
 (0)