From 0b44d4639dc8ad0558ec67bc5d6544718ba13e04 Mon Sep 17 00:00:00 2001 From: Ryan G <78384369+SpongeManiac@users.noreply.github.com> Date: Sun, 11 Jun 2023 20:35:37 -0700 Subject: [PATCH] Update authentication.cr --- src/invidious/routes/api/v1/authentication.cr | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/invidious/routes/api/v1/authentication.cr b/src/invidious/routes/api/v1/authentication.cr index 6347467b..821a23c0 100644 --- a/src/invidious/routes/api/v1/authentication.cr +++ b/src/invidious/routes/api/v1/authentication.cr @@ -15,14 +15,17 @@ module Invidious::Routes::API::V1::Authentication if old_sid != "" Invidious::Database::SessionIDs.delete(sid: old_sid) end - token = Invidious::Database::SessionIDs.select_token(sid: sid) - response = JSON.build do |json| - json.object do - json.field "session", token[:session] - json.field "issued", token[:issued].to_unix + if token = Invidious::Database::SessionIDs.select_token(sid: sid) + response = JSON.build do |json| + json.object do + json.field "session", token[:session] + json.field "issued", token[:issued].to_unix + end end + return response + else + return error_json(500, "Token not found") end - return response else return error_json(401, "Wrong username or password") end