mirror of
https://github.com/iv-org/invidious.git
synced 2025-04-20 15:45:46 -04:00
Update authentication.cr
This commit is contained in:
parent
9e120472cf
commit
4835ed314b
@ -19,16 +19,35 @@ module Invidious::Routes::API::V1::Authentication
|
||||
|
||||
if creds
|
||||
# user is registering
|
||||
password = creds.password
|
||||
username = creds.username
|
||||
if creds.password.empty?
|
||||
return error_json(401, "Password cannot be empty")
|
||||
end
|
||||
# See https://security.stackexchange.com/a/39851
|
||||
if creds.password.bytesize > 55
|
||||
return error_json(400, "Password cannot be longer than 55 characters")
|
||||
password = creds.password
|
||||
|
||||
if username.nil? || username.empty?
|
||||
return error_json(401, "User ID is a required field")
|
||||
end
|
||||
|
||||
if password.nil? || password.empty?
|
||||
return error_json(401, "Password is a required field")
|
||||
end
|
||||
|
||||
if username.empty?
|
||||
return error_json(401, "Username cannot be empty")
|
||||
end
|
||||
|
||||
if password.empty?
|
||||
return error_json(401, "Password cannot be empty")
|
||||
end
|
||||
|
||||
if username.bytesize > 254
|
||||
return error_json(401)
|
||||
end
|
||||
|
||||
# See https://security.stackexchange.com/a/39851
|
||||
if password.bytesize > 55
|
||||
return error_json(401, "Password cannot be longer than 55 characters")
|
||||
end
|
||||
|
||||
username = username.byte_slice(0, 254)
|
||||
password = password.byte_slice(0, 55)
|
||||
|
||||
if CONFIG.captcha_enabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user