overleaf/services/web/app/coffee/Features/Security/LoginRateLimiter.coffee

22 lines
453 B
CoffeeScript
Raw Normal View History

RateLimiter = require('../../infrastructure/RateLimiter')
2014-02-12 05:23:40 -05:00
ONE_MIN = 60
ATTEMPT_LIMIT = 10
2014-02-12 05:23:40 -05:00
module.exports =
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 = ->)->
RateLimiter.clearRateLimit 'login', email, callback