Reputation: 11098
I've tried a few things but can't seem to get my head round it. I've been practicing and know how to do this using email but how can I do it using username?
def self.authenticate(username, password)
user = find_by_name(username)
if user && user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
user
else
nil
end
end
Upvotes: 0
Views: 3505
Reputation: 222168
Change
user = find_by_name(username)
to
user = find_by_username(username)
Upvotes: 3