mirror of
https://github.com/moparisthebest/discourse-migratepassword
synced 2024-11-21 08:25:08 -05:00
Add check_smf_bcrypt for bcrypt(sha1(user+pass))
This commit is contained in:
parent
57c2c06c7a
commit
6bc90f3004
21
plugin.rb
21
plugin.rb
@ -105,15 +105,7 @@ after_initialize do
|
||||
end
|
||||
|
||||
def self.check_all(password, crypted_pass)
|
||||
AlternativePassword::check_vbulletin(password, crypted_pass) ||
|
||||
AlternativePassword::check_vbulletin5(password, crypted_pass) ||
|
||||
AlternativePassword::check_ipb(password, crypted_pass) ||
|
||||
AlternativePassword::check_smf(password, crypted_pass) ||
|
||||
AlternativePassword::check_md5(password, crypted_pass) ||
|
||||
AlternativePassword::check_wordpress(password, crypted_pass) ||
|
||||
AlternativePassword::check_bcrypt(password, crypted_pass) ||
|
||||
AlternativePassword::check_sha256(password, crypted_pass) ||
|
||||
AlternativePassword::check_wbblite(password, crypted_pass)
|
||||
AlternativePassword::check_smf_bcrypt(password, crypted_pass)
|
||||
end
|
||||
|
||||
def self.check_bcrypt(password, crypted_pass)
|
||||
@ -150,6 +142,17 @@ after_initialize do
|
||||
hash == sha1.hexdigest
|
||||
end
|
||||
|
||||
def self.check_smf_bcrypt(password, crypted_pass)
|
||||
user, hash = crypted_pass.split(':', 2)
|
||||
sha1 = Digest::SHA1.new
|
||||
sha1.update user + password
|
||||
begin
|
||||
BCrypt::Password.new(hash) == sha1.hexdigest
|
||||
rescue
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_ipb(password, crypted_pass)
|
||||
salt, hash = crypted_pass.split(':', 2)
|
||||
!salt.nil? && hash == Digest::MD5.hexdigest(Digest::MD5.hexdigest(salt) + Digest::MD5.hexdigest(password))
|
||||
|
Loading…
Reference in New Issue
Block a user