Skip to content

Commit 4ad3b64

Browse files
committed
Whoops, forgot to update some of the documentation
1 parent ad379b4 commit 4ad3b64

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ For details see [node-memcached](http://github.com/3rd-Eden/node-memcached).
5959
-------------------------------
6060
- `prevent(req, res, next)` Middleware that will bounce requests that happen faster than
6161
the current wait time by calling `failCallback`. Equivilent to `getMiddleware(null)`
62-
- `getMiddleware(key)` Generates middleware that will bounce requests with the same `key` and IP address
62+
- `getMiddleware(options)` Generates middleware that will bounce requests with the same `key` and IP address
6363
that happen faster than the current wait time by calling `failCallback`.
64-
`key` can be a string. Alternatively, key can be a `function(req, res, next)`
65-
that returns a string or calls `next`, passing a string as the first parameter.
6664
Also attaches a function at `req.brute.reset` that can be called to reset the
6765
counter for the current ip and key. This functions the the `reset` instance method,
6866
but without the need to explicitly pass the `ip` and `key` paramters
67+
- `key` can be a string or alternatively it can be a `function(req, res, next)`
68+
that or calls `next`, passing a string as the first parameter.
69+
- `failCallback` Allows you to override the value of `failCallback` for this middleware
6970
- `reset(ip, key, next)` Resets the wait time between requests back to its initial value. You can pass `null`
7071
for `key` if you want to reset a request protected by `protect`.
7172
- `getIPFromRequest(req)` Uses the current proxy trust settings to get the current IP from a request object
@@ -118,9 +119,11 @@ var globalBruteforce = new ExpressBrute(store, {
118119

119120
app.post('/auth',
120121
globalBruteforce.prevent,
121-
userBruteforce.getMiddleware(function(req, res, next) {
122-
// prevent too many attempts for the same username
123-
return req.body.username;
122+
userBruteforce.getMiddleware({
123+
key: function(req, res, next) {
124+
// prevent too many attempts for the same username
125+
return req.body.username;
126+
}
124127
}),
125128
function (req, res, next) {
126129
if (User.isValidLogin(req.body.username, req.body.password)) { // omitted for the sake of conciseness

0 commit comments

Comments
 (0)