2016-12-19 09:10:51 -05:00
|
|
|
RateLimiter = require('../../infrastructure/RateLimiter')
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
ONE_MIN = 60
|
|
|
|
ATTEMPT_LIMIT = 10
|
|
|
|
|
2016-12-19 09:10:51 -05:00
|
|
|
|
2014-02-12 05:23:40 -05:00
|
|
|
module.exports =
|
2016-12-19 09:10:51 -05:00
|
|
|
|
|
|
|
processLoginRequest: (email, callback) ->
|
|
|
|
opts =
|
|
|
|
endpointName: 'login'
|
|
|
|
throttle: ATTEMPT_LIMIT
|
|
|
|
timeInterval: ONE_MIN * 2
|
|
|
|
subjectName: email
|
|
|
|
RateLimiter.addCount opts, (err, shouldAllow) ->
|
|
|
|
callback(err, shouldAllow)
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
recordSuccessfulLogin: (email, callback = ->)->
|
2016-12-19 09:10:51 -05:00
|
|
|
RateLimiter.clearRateLimit 'login', email, callback
|
|
|
|
|