in User#authenticate:
* make search by username case sensitive as in prod there already are
  usernames diffing only in case
* use guard clause instead of nesting
This commit is contained in:
Absurdon 2020-04-13 15:34:12 +00:00
parent 88a6c697cc
commit 6f05d47a8d

View file

@ -449,7 +449,9 @@ class User < ActiveRecord::Base
end
def self.authenticate(login)
if (user = where("LOWER(username) = LOWER(?)", login[:username]).first)
user = where('username = ?', login[:username]).first
return nil unless user
begin
case user.password_hash
when User::PASSWORD_SCRYPT
@ -480,8 +482,6 @@ class User < ActiveRecord::Base
# return nil
end
end
return nil
end
def self.get(id)
id ? User.find(id) : ""