Upgrade passwords to the latest hashing scheme on login
This commit is contained in:
parent
15d29c646b
commit
b9daf06684
3 changed files with 28 additions and 1 deletions
|
@ -70,7 +70,14 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
user = nil if user and not PasswordHash.check(user.pass_crypt, user.pass_salt, options[:password])
|
||||
if user and PasswordHash.check(user.pass_crypt, user.pass_salt, options[:password])
|
||||
if PasswordHash.upgrade?(user.pass_crypt, user.pass_salt)
|
||||
user.pass_crypt, user.pass_salt = PasswordHash.create(options[:password])
|
||||
user.save
|
||||
end
|
||||
else
|
||||
user = nil
|
||||
end
|
||||
elsif options[:token]
|
||||
token = UserToken.find_by_token(options[:token])
|
||||
user = token.user if token
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue