Don't use v1 cached captchas for new threads. #1300

This commit is contained in:
ccd0 2017-02-21 00:00:42 -08:00
parent d7287b5185
commit 73c8054b64
4 changed files with 9 additions and 7 deletions

View File

@ -21,9 +21,11 @@ Captcha.cache =
@captchas = captchas @captchas = captchas
@count() @count()
getOne: -> getOne: (isReply) ->
@clear() @clear()
if (captcha = @captchas.shift()) i = @captchas.findIndex((x) -> isReply or !x.challenge?)
if i >= 0
captcha = @captchas.splice(i, 1)[0]
$.set 'captchas', @captchas $.set 'captchas', @captchas
@count() @count()
captcha captcha

View File

@ -134,8 +134,8 @@ Captcha.v1 =
delete @occupied delete @occupied
@beforeSetup() if @nodes @beforeSetup() if @nodes
getOne: -> getOne: (isReply) ->
if (captcha = Captcha.cache.getOne()) if (captcha = Captcha.cache.getOne isReply)
captcha captcha
else else
challenge = @nodes.img.alt challenge = @nodes.img.alt

View File

@ -153,8 +153,8 @@ Captcha.v2 =
$.rm node $.rm node
return return
getOne: -> getOne: (isReply) ->
Captcha.cache.getOne() Captcha.cache.getOne isReply
save: (pasted, token) -> save: (pasted, token) ->
Captcha.cache.save Captcha.cache.save

View File

@ -621,7 +621,7 @@ QR =
err or= 'Original comment required.' err or= 'Original comment required.'
if QR.captcha.isEnabled and !err if QR.captcha.isEnabled and !err
captcha = QR.captcha.getOne() captcha = QR.captcha.getOne(!!threadID)
unless captcha unless captcha
err = 'No valid captcha.' err = 'No valid captcha.'
QR.captcha.setup(!QR.cooldown.auto or d.activeElement is QR.nodes.status) QR.captcha.setup(!QR.cooldown.auto or d.activeElement is QR.nodes.status)