Captcha Update

+ Scope parameter in captcha generation
This commit is contained in:
Ryan G 2023-06-12 23:31:40 -07:00
parent 9f2ba07367
commit ae058da25c
2 changed files with 3 additions and 3 deletions

View file

@ -36,7 +36,7 @@ module Invidious::Routes::API::V1::Authentication
# send captcha if enabled # send captcha if enabled
if CONFIG.captcha_enabled if CONFIG.captcha_enabled
# send captcha # send captcha
captcha = Invidious::User::Captcha.generate_text(HMAC_KEY) captcha = Invidious::User::Captcha.generate_text(HMAC_KEY, ":captcha")
# puts captcha # puts captcha
response = JSON.build do |json| response = JSON.build do |json|
json.object do json.object do

View file

@ -61,12 +61,12 @@ struct Invidious::User
} }
end end
def generate_text(key) def generate_text(key, scope = ":login")
response = make_client(TEXTCAPTCHA_URL, &.get("/github.com/iv.org/invidious.json").body) response = make_client(TEXTCAPTCHA_URL, &.get("/github.com/iv.org/invidious.json").body)
response = JSON.parse(response) response = JSON.parse(response)
tokens = response["a"].as_a.map do |answer| tokens = response["a"].as_a.map do |answer|
generate_response(answer.as_s, {":login"}, key, use_nonce: true) generate_response(answer.as_s, {scope}, key, use_nonce: true)
end end
return { return {