@@ -59,13 +59,14 @@ For details see [node-memcached](http://github.com/3rd-Eden/node-memcached).
59
59
-------------------------------
60
60
- ` prevent(req, res, next) ` Middleware that will bounce requests that happen faster than
61
61
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
63
63
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.
66
64
Also attaches a function at ` req.brute.reset ` that can be called to reset the
67
65
counter for the current ip and key. This functions the the ` reset ` instance method,
68
66
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
69
70
- ` reset(ip, key, next) ` Resets the wait time between requests back to its initial value. You can pass ` null `
70
71
for ` key ` if you want to reset a request protected by ` protect ` .
71
72
- ` 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, {
118
119
119
120
app .post (' /auth' ,
120
121
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
+ }
124
127
}),
125
128
function (req , res , next ) {
126
129
if (User .isValidLogin (req .body .username , req .body .password )) { // omitted for the sake of conciseness
0 commit comments