Merge pull request #70 from mozilla/rfk/block-banned-emails
Block all actions for emails that are explicitly banned
This commit is contained in:
Коммит
66f0137a36
|
@ -81,8 +81,11 @@ module.exports = function (RATE_LIMIT_INTERVAL_MS, BLOCK_INTERVAL_MS, MAX_EMAILS
|
|||
|
||||
EmailRecord.prototype.isBlocked = function () {
|
||||
var rateLimited = !!(this.rl && (now() - this.rl < RATE_LIMIT_INTERVAL_MS))
|
||||
var banned = !!(this.bk && (now() - this.bk < BLOCK_INTERVAL_MS))
|
||||
return rateLimited || banned
|
||||
return rateLimited || this.isBanned()
|
||||
}
|
||||
|
||||
EmailRecord.prototype.isBanned = function () {
|
||||
return !!(this.bk && (now() - this.bk < BLOCK_INTERVAL_MS))
|
||||
}
|
||||
|
||||
EmailRecord.prototype.block = function () {
|
||||
|
@ -105,7 +108,7 @@ module.exports = function (RATE_LIMIT_INTERVAL_MS, BLOCK_INTERVAL_MS, MAX_EMAILS
|
|||
}
|
||||
|
||||
EmailRecord.prototype.update = function (action) {
|
||||
if (EMAIL_ACTIONS.indexOf(action) === -1) {
|
||||
if (!this.isBanned() && EMAIL_ACTIONS.indexOf(action) === -1) {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,19 @@ test(
|
|||
t.equal(er.update('accountCreate'), 0, 'email action above the email limit')
|
||||
t.equal(er.isBlocked(), true, 'account is now blocked')
|
||||
t.equal(er.update('accountCreate'), 0, 'email action in a blocked account')
|
||||
|
||||
er.rl = 2000
|
||||
t.equal(er.isBlocked(), true, 'account is blocked')
|
||||
t.equal(er.isBanned(), false, 'account is not outright banned')
|
||||
t.equal(er.update('accountCreate'), 1, 'email action is blocked')
|
||||
t.equal(er.update('accountLogin'), 0, 'non-email action is not blocked')
|
||||
er.rl = 0
|
||||
er.bk = 2000
|
||||
t.equal(er.isBlocked(), true, 'account is blocked')
|
||||
t.equal(er.isBanned(), true, 'account is outright banned')
|
||||
t.equal(er.update('accountCreate'), 1, 'email action is blocked')
|
||||
t.equal(er.update('accountLogin'), 1, 'non-email action is blocked')
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче