Expiration date should be nil when theres no token

This commit is contained in:
Alex Ling 2021-03-05 11:01:00 +00:00
parent 371c8056e7
commit 8aab113aab
2 changed files with 9 additions and 3 deletions

View File

@ -963,7 +963,13 @@ struct APIRouter
Koa.tags ["admin", "mangadex"]
get "/api/admin/mangadex/search" do |env|
begin
token, expires = Storage.default.get_md_token get_username env
username = get_username env
token, expires = Storage.default.get_md_token username
unless expires && token
raise "No token found for user #{username}"
end
client = MangaDex::Client.from_config
client.token = token
client.token_expires = expires

View File

@ -530,9 +530,9 @@ class Storage
end
end
def get_md_token(username) : Tuple(String?, Time)
def get_md_token(username) : Tuple(String?, Time?)
token = nil
expires = Time.utc
expires = nil
MainFiber.run do
get_db do |db|
db.query_one? "select token, expire from md_account where " \