From b66a15e890472ff12f9dd247e6da7d65f246f3ee Mon Sep 17 00:00:00 2001 From: Ryan G <78384369+SpongeManiac@users.noreply.github.com> Date: Mon, 12 Jun 2023 21:50:22 -0700 Subject: [PATCH] Update authentication.cr --- src/invidious/routes/api/v1/authentication.cr | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/invidious/routes/api/v1/authentication.cr b/src/invidious/routes/api/v1/authentication.cr index 69dde684..17af9615 100644 --- a/src/invidious/routes/api/v1/authentication.cr +++ b/src/invidious/routes/api/v1/authentication.cr @@ -43,14 +43,14 @@ module Invidious::Routes::API::V1::Authentication # check if user is responding to captcha if captcha_response # process captcha response - # answer = captcha_response.answer - # answer = answer.lstrip('0') - # answer = OpenSSL::HMAC.hexdigest(:sha256, HMAC_KEY, answer) - # begin - # validate_request(, answer, env.request, HMAC_KEY, locale) - # rescue ex - # return error_jsonror(400, ex) - # end + answer = captcha_response.answer + answer = answer.lstrip('0') + answer = OpenSSL::HMAC.hexdigest(:sha256, HMAC_KEY, answer) + begin + validate_request(captcha_response.tokens[0], answer, env.request, HMAC_KEY, locale) + rescue ex + return error_jsonror(400, ex) + end else # send captcha captcha = Invidious::User::Captcha.generate_text(HMAC_KEY) @@ -144,7 +144,7 @@ struct CaptchaResponse property username : String property password : String property answer : String - # property tokens : Array() + property tokens : Array(String) end struct Credentials