jaredhanson/passport — Issue #10: Document how to establish sessions manually
Author: thatmarvin
Created: 2012-01-26 03:47:04+00:00
State: open

Under "Custom Callback" in http://passportjs.org/guide/authenticate.html, the docs mention "… it becomes the application's responsibility to establish a session".

Since passport has already implemented this, it makes sense to just invoke it from the app.

The following code, adopted from in `middleware/authenticate.js`, seems to do the trick:

``` javascript
req.logIn(user, function (err) {
if (err) {
throw err;
}

// Session is established; redirect to destination or do something else
});
```
If this indeed correct, I think it's worthwhile to document it? Otherwise, is there a better way to do this?