Skip to content

Commit 96bc94a

Browse files
committed
Merge remote-tracking branch 'zrisher/master' jaredhanson#151
2 parents bbb954c + 3282b88 commit 96bc94a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ password. The strategy requires a `verify` callback, which accepts these
3131
credentials and calls `done` providing a user.
3232

3333
```js
34+
passport = require('passport');
35+
LocalStrategy = require('passport-local').Strategy;
36+
3437
passport.use(new LocalStrategy(
3538
function(username, password, done) {
3639
User.findOne({ username: username }, function (err, user) {
@@ -96,12 +99,17 @@ passport.use(new LocalStrategy({
9699
#### Authenticate Requests
97100

98101
Use `passport.authenticate()`, specifying the `'local'` strategy, to
99-
authenticate requests.
102+
authenticate requests. It searches for fields in the query string and
103+
`req.body`, so ensure body parsers are in place if these fields are
104+
sent in the body.
100105

101106
For example, as route middleware in an [Express](http://expressjs.com/)
102107
application:
103108

104109
```js
110+
app.use(require('body-parser').urlencoded({ extended: true }));
111+
app.use(passport.initialize());
112+
105113
app.post('/login',
106114
passport.authenticate('local', { failureRedirect: '/login' }),
107115
function(req, res) {

0 commit comments

Comments
 (0)