Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ accordingly.
Use `passport.authenticate()`, specifying the `'local'` strategy, to
authenticate requests.

When this function is present in a route, passport will verify for `usernameField`and `passwordField` in the request. A bad request error will be thrown when these attributes are not provided. It is used only for login purposes, to verify if the user has permission to access the route, please see `Authorizing Requests` instead.

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

Expand All @@ -112,6 +114,20 @@ app.post('/login',
res.redirect('/');
});
```
#### Authorizing Requests

Use `req.isAuthorized()` to verify if the user is already authenticated and should have or not access to the route.

```js
app.get('/profile',
function(req, res){
if (req.isAuthenticated()) {
//do something
} else {
res.redirect('/login');
}
});
```

## Examples

Expand Down