mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-28 23:48:31 +00:00
Remove residual account_type logic
This commit is contained in:
parent
3b77a2eac1
commit
2d289b3d12
@ -30,45 +30,37 @@ module Invidious::Routes::Login
|
|||||||
email = env.params.body["email"]?.try &.downcase.byte_slice(0, 254)
|
email = env.params.body["email"]?.try &.downcase.byte_slice(0, 254)
|
||||||
password = env.params.body["password"]?
|
password = env.params.body["password"]?
|
||||||
|
|
||||||
account_type = env.params.query["type"]?
|
if email.nil? || email.empty?
|
||||||
account_type ||= "invidious"
|
return error_template(401, "User ID is a required field")
|
||||||
|
end
|
||||||
|
|
||||||
case account_type
|
if password.nil? || password.empty?
|
||||||
when "invidious"
|
return error_template(401, "Password is a required field")
|
||||||
if email.nil? || email.empty?
|
end
|
||||||
return error_template(401, "User ID is a required field")
|
|
||||||
end
|
|
||||||
|
|
||||||
if password.nil? || password.empty?
|
user = Invidious::Database::Users.select(email: email)
|
||||||
return error_template(401, "Password is a required field")
|
|
||||||
end
|
|
||||||
|
|
||||||
user = Invidious::Database::Users.select(email: email)
|
if user
|
||||||
|
if Crypto::Bcrypt::Password.new(user.password.not_nil!).verify(password.byte_slice(0, 55))
|
||||||
|
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
||||||
|
Invidious::Database::SessionIDs.insert(sid, email)
|
||||||
|
|
||||||
if user
|
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
||||||
if Crypto::Bcrypt::Password.new(user.password.not_nil!).verify(password.byte_slice(0, 55))
|
|
||||||
sid = Base64.urlsafe_encode(Random::Secure.random_bytes(32))
|
|
||||||
Invidious::Database::SessionIDs.insert(sid, email)
|
|
||||||
|
|
||||||
env.response.cookies["SID"] = Invidious::User::Cookies.sid(CONFIG.domain, sid)
|
|
||||||
else
|
|
||||||
return error_template(401, "Wrong username or password")
|
|
||||||
end
|
|
||||||
|
|
||||||
# Since this user has already registered, we don't want to overwrite their preferences
|
|
||||||
if env.request.cookies["PREFS"]?
|
|
||||||
cookie = env.request.cookies["PREFS"]
|
|
||||||
cookie.expires = Time.utc(1990, 1, 1)
|
|
||||||
env.response.cookies << cookie
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
return error_template(401, "Wrong username or password")
|
return error_template(401, "Wrong username or password")
|
||||||
end
|
end
|
||||||
|
|
||||||
env.redirect referer
|
# Since this user has already registered, we don't want to overwrite their preferences
|
||||||
|
if env.request.cookies["PREFS"]?
|
||||||
|
cookie = env.request.cookies["PREFS"]
|
||||||
|
cookie.expires = Time.utc(1990, 1, 1)
|
||||||
|
env.response.cookies << cookie
|
||||||
|
end
|
||||||
else
|
else
|
||||||
env.redirect referer
|
return error_template(401, "Wrong username or password")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
env.redirect referer
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.signup_page(env)
|
def self.signup_page(env)
|
||||||
@ -88,9 +80,6 @@ module Invidious::Routes::Login
|
|||||||
password = nil
|
password = nil
|
||||||
captcha = nil
|
captcha = nil
|
||||||
|
|
||||||
account_type = env.params.query["type"]?
|
|
||||||
account_type ||= "invidious"
|
|
||||||
|
|
||||||
captcha_type = env.params.query["captcha"]?
|
captcha_type = env.params.query["captcha"]?
|
||||||
captcha_type ||= "image"
|
captcha_type ||= "image"
|
||||||
|
|
||||||
|
@ -81,8 +81,6 @@ struct Invidious::User
|
|||||||
end
|
end
|
||||||
captcha_type ||= "image"
|
captcha_type ||= "image"
|
||||||
|
|
||||||
account_type = "invidious"
|
|
||||||
|
|
||||||
if captcha_type == "image"
|
if captcha_type == "image"
|
||||||
captcha = Invidious::User::Captcha.generate_image(HMAC_KEY)
|
captcha = Invidious::User::Captcha.generate_image(HMAC_KEY)
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user