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
@count()
getOne: ->
getOne: (isReply) ->
@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
@count()
captcha

View File

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

View File

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

View File

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