Fix text captcha validation

This commit is contained in:
syeopite 2023-07-27 11:46:16 -07:00
parent 8a24dd0e0f
commit 4dcf2b08e5
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -215,15 +215,27 @@ module Invidious::Routes::Login
return error_template(400, "Erroneous CAPTCHA")
end
# Text Captcha Validation
# There's a possibility that there could be multiple tokens and therefore we'd need to
# check them all and only error once we've made sure that none of them passes the check.
found_valid_captcha = false
error_exception = Exception.new
tokens.each do |tok|
begin
validate_request(tok, answer, env.request, HMAC_KEY, locale)
found_valid_captcha = true
break
rescue ex
return error_template(400, "Erroneous CAPTCHA")
error_exception = ex
end
end
# Error when validation fail
if !found_valid_captcha
return error_template(400, "Erroneous CAPTCHA")
end
end
self.register_user(env, email, password)