@@ -101,13 +101,23 @@ var failCallback = function (req, res, next, nextValidRequestDate) {
101101 req .flash (' error' , " You've made too many failed attempts in a short period of time, please try again " + moment (nextValidRequestDate).fromNow ());
102102 res .redirect (' /login' ); // brute force protection triggered, send them back to the login page
103103};
104+ var handleStoreError = handleStoreError : function (error ) {
105+ log .error (error); // log this error so we can figure out what went wrong
106+ // cause node to exit, hopefully restarting the process fixes the problem
107+ throw {
108+ message: error .message ,
109+ parent: error .parent
110+ };
111+ }
104112// Start slowing requests after 5 failed attempts to do something for the same user
105113var userBruteforce = new ExpressBrute (store, {
106114 freeRetries: 5 ,
107115 proxyDepth: 1 ,
108116 minWait: 5 * 60 * 1000 , // 5 minutes
109117 maxWait: 60 * 60 * 1000 , // 1 hour,
110- failCallback: failCallback
118+ failCallback: failCallback,
119+ handleStoreError: handleStoreError
120+ }
111121});
112122// No more than 1000 login attempts per day per IP
113123var globalBruteforce = new ExpressBrute (store, {
@@ -118,7 +128,8 @@ var globalBruteforce = new ExpressBrute(store, {
118128 minWait: 25 * 60 * 60 * 1000 , // 1 day 1 hour (should never reach this wait time)
119129 maxWait: 25 * 60 * 60 * 1000 , // 1 day 1 hour (should never reach this wait time)
120130 lifetime: 24 * 60 * 60 , // 1 day (seconds not milliseconds)
121- failCallback: failCallback
131+ failCallback: failCallback,
132+ handleStoreError: handleStoreError
122133});
123134
124135app .post (' /auth' ,
0 commit comments