From 40ca8898d4cc0da7f59ec72b89e458ff4227f132 Mon Sep 17 00:00:00 2001 From: Ryan G <78384369+SpongeManiac@users.noreply.github.com> Date: Tue, 13 Jun 2023 00:20:58 -0700 Subject: [PATCH] Update authentication.cr --- src/invidious/routes/api/v1/authentication.cr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/invidious/routes/api/v1/authentication.cr b/src/invidious/routes/api/v1/authentication.cr index 5ea6e99c..e528b9e2 100644 --- a/src/invidious/routes/api/v1/authentication.cr +++ b/src/invidious/routes/api/v1/authentication.cr @@ -1,10 +1,11 @@ module Invidious::Routes::API::V1::Authentication def self.register(env) env.response.content_type = "application/json" + body_json = env.request.body || "{}" if CONFIG.registration_enabled creds = nil begin - creds = Credentials.from_json(env.request.body || "{}") + creds = Credentials.from_json(body_json) rescue end # get user info @@ -36,7 +37,11 @@ module Invidious::Routes::API::V1::Authentication password = password.byte_slice(0, 55) # send captcha if enabled if CONFIG.captcha_enabled - captcha_response = CaptchaResponse.from_json(env.request.body || "{}") + captcha_response = nil + begin + captcha_response = CaptchaResponse.from_json(body_json) + rescue + end if captcha_response answer = captcha_response.answer tokens = captcha_response.tokens