Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ramseydsilva committed Apr 4, 2014
1 parent a5960c1 commit 5ef027e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ socketer.anonSocket(app, function(socket) {
### authSocket

authSocket takes your express app as an argument, login credentials in the form of a dict, login url, and a
callback that returns an anonymous socket that you can use to poll your server as an anonymous user.
callback that returns a socket that has been authenticated via the login url.

```
var socketer = request('socketer');
Expand All @@ -54,6 +54,26 @@ socketer.authSocket(app, {'username': 'Ramsey', 'password': 'Ramseypass'}, '/log
});
```

The login url accepts a post method, and csrf has to be turned off for testing. In your app.js file, you can have something like:

```
if (process.env.NODE_ENV == 'production') {
app.use(express.csrf());
app.use(function(req, res, next) {
res.locals.token = req.csrfToken();
});
};
// or
if (process.env.NODE_ENV != 'mochaTesting') {
app.use(express.csrf());
app.use(function(req, res, next) {
res.locals.token = req.csrfToken();
});
};
```

## Tips

1. After every test and before you call the done method, you can choose to disconnect the socket by calling
Expand Down

0 comments on commit 5ef027e

Please sign in to comment.