mirror of
https://github.com/moparisthebest/discourse-migratepassword
synced 2024-11-21 08:25:08 -05:00
Catch exception; add sha256 support
This commit is contained in:
parent
498474ceac
commit
1e6bd8f9bc
15
plugin.rb
15
plugin.rb
@ -105,11 +105,16 @@ after_initialize do
|
||||
AlternativePassword::check_vbulletin(password, crypted_pass) ||
|
||||
AlternativePassword::check_md5(password, crypted_pass) ||
|
||||
AlternativePassword::check_wordpress(password, crypted_pass) ||
|
||||
AlternativePassword::check_bcrypt(password, crypted_pass)
|
||||
AlternativePassword::check_bcrypt(password, crypted_pass) ||
|
||||
AlternativePassword::check_sha256(password, crypted_pass)
|
||||
end
|
||||
|
||||
def self.check_bcrypt(password, crypted_pass)
|
||||
BCrypt::Password.new(crypted_pass) == password
|
||||
begin
|
||||
BCrypt::Password.new(crypted_pass) == password
|
||||
rescue
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def self.check_vbulletin(password, crypted_pass)
|
||||
@ -125,6 +130,12 @@ after_initialize do
|
||||
hasher = WordpressHash.new(8)
|
||||
hasher.check(password, crypted_pass)
|
||||
end
|
||||
|
||||
def self.check_sha256(password, crypted_pass)
|
||||
sha256 = Digest::SHA256.new
|
||||
sha256.update password
|
||||
crypted_pass == sha256.hexdigest
|
||||
end
|
||||
end
|
||||
|
||||
class ::User
|
||||
|
Loading…
Reference in New Issue
Block a user