mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-07 00:11:47 +01:00
Remove support for deprecated password-hashing algorithm
* Remove all methods implementing and checking for the old algorithm * Document a pre-upgrade step to check for remaining obsolete passwords * Remove config.salt
This commit is contained in:
parent
6caa2de318
commit
ea0d40060a
19 changed files with 17 additions and 164 deletions
|
|
@ -185,25 +185,8 @@ class User < ActiveRecord::Base
|
|||
save
|
||||
end
|
||||
|
||||
# Returns true if the user has a password hashed using SHA-1.
|
||||
def uses_deprecated_password?
|
||||
crypted_password =~ /^[a-f0-9]{40}$/i
|
||||
end
|
||||
|
||||
def password_matches?(pass)
|
||||
if uses_deprecated_password?
|
||||
crypted_password == sha1(pass)
|
||||
else
|
||||
BCrypt::Password.new(crypted_password) == pass
|
||||
end
|
||||
end
|
||||
|
||||
def salted(s)
|
||||
"#{Tracks::Config.salt}--#{s}--"
|
||||
end
|
||||
|
||||
def sha1(s)
|
||||
Digest::SHA1.hexdigest(salted(s))
|
||||
BCrypt::Password.new(crypted_password) == pass
|
||||
end
|
||||
|
||||
def create_hash(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue