LoginRateLimiter.coffee 453 B

123456789101112131415161718192021
  1. RateLimiter = require('../../infrastructure/RateLimiter')
  2. ONE_MIN = 60
  3. ATTEMPT_LIMIT = 10
  4. module.exports =
  5. processLoginRequest: (email, callback) ->
  6. opts =
  7. endpointName: 'login'
  8. throttle: ATTEMPT_LIMIT
  9. timeInterval: ONE_MIN * 2
  10. subjectName: email
  11. RateLimiter.addCount opts, (err, shouldAllow) ->
  12. callback(err, shouldAllow)
  13. recordSuccessfulLogin: (email, callback = ->)->
  14. RateLimiter.clearRateLimit 'login', email, callback