Update authentication.cr

This commit is contained in:
Ryan G 2023-06-11 20:35:37 -07:00
parent 37c9af0bcb
commit 0b44d4639d

View File

@ -15,14 +15,17 @@ module Invidious::Routes::API::V1::Authentication
if old_sid != "" if old_sid != ""
Invidious::Database::SessionIDs.delete(sid: old_sid) Invidious::Database::SessionIDs.delete(sid: old_sid)
end end
token = Invidious::Database::SessionIDs.select_token(sid: sid) if token = Invidious::Database::SessionIDs.select_token(sid: sid)
response = JSON.build do |json| response = JSON.build do |json|
json.object do json.object do
json.field "session", token[:session] json.field "session", token[:session]
json.field "issued", token[:issued].to_unix json.field "issued", token[:issued].to_unix
end
end end
return response
else
return error_json(500, "Token not found")
end end
return response
else else
return error_json(401, "Wrong username or password") return error_json(401, "Wrong username or password")
end end