Update authentication.cr

This commit is contained in:
Ryan G 2023-06-11 21:54:55 -07:00
parent 60f2121361
commit d9194854e2

View File

@ -9,7 +9,7 @@ module Invidious::Routes::API::V1::Authentication
user = Invidious::Database::Users.select(email: creds.username)
old_sid = creds.token
if user
if Crypto::Bcrypt::Password.new(creds.password).verify(creds.password.byte_slice(0, 55))
if Crypto::Bcrypt::Password.new(user.password.not_nil!).verify(creds.password.byte_slice(0, 55))
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
Invidious::Database::SessionIDs.insert(sid: sid, email: creds.username)
if old_sid != ""