mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-28 15:38:30 +00:00
Fix captcha validation
This commit is contained in:
parent
0fd4beeac8
commit
9be4585d16
@ -198,6 +198,8 @@ module Invidious::Routes::Login
|
||||
|
||||
case captcha_type
|
||||
when "image"
|
||||
LOGGER.trace("Validating image Captcha")
|
||||
|
||||
answer = answer.lstrip('0')
|
||||
answer = OpenSSL::HMAC.hexdigest(:sha256, HMAC_KEY, answer)
|
||||
|
||||
@ -207,7 +209,7 @@ module Invidious::Routes::Login
|
||||
return error_template(400, "Erroneous CAPTCHA")
|
||||
end
|
||||
else # "text"
|
||||
answer = Digest::MD5.hexdigest(answer)
|
||||
answer = Digest::MD5.hexdigest(answer.downcase.strip)
|
||||
|
||||
if tokens.empty?
|
||||
return error_template(400, "Erroneous CAPTCHA")
|
||||
|
@ -57,7 +57,7 @@ struct Invidious::User
|
||||
|
||||
return {
|
||||
question: image,
|
||||
tokens: {generate_response(answer, {":login"}, key, use_nonce: true)},
|
||||
tokens: {generate_response(answer, {":captcha"}, key, use_nonce: true)},
|
||||
}
|
||||
end
|
||||
|
||||
@ -66,7 +66,7 @@ struct Invidious::User
|
||||
response = JSON.parse(response)
|
||||
|
||||
tokens = response["a"].as_a.map do |answer|
|
||||
generate_response(answer.as_s, {":login"}, key, use_nonce: true)
|
||||
generate_response(answer.as_s, {":captcha"}, key, use_nonce: true)
|
||||
end
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user