mirror of
https://github.com/moparisthebest/discourse-migratepassword
synced 2025-02-16 06:50:10 -05:00
commit
0537834c93
12
plugin.rb
12
plugin.rb
@ -12,6 +12,7 @@
|
|||||||
# for Phorum #{password} md5(pass)
|
# for Phorum #{password} md5(pass)
|
||||||
# for Wordpress #{password} phpass(8).crypt(pass)
|
# for Wordpress #{password} phpass(8).crypt(pass)
|
||||||
# for SMF #{username}:#{password} sha1(user+pass)
|
# for SMF #{username}:#{password} sha1(user+pass)
|
||||||
|
# for WBBlite #{salt}:#{hash} sha1(salt+sha1(salt+sha1(pass)))
|
||||||
|
|
||||||
gem 'bcrypt', '3.1.3'
|
gem 'bcrypt', '3.1.3'
|
||||||
|
|
||||||
@ -109,7 +110,8 @@ after_initialize do
|
|||||||
AlternativePassword::check_md5(password, crypted_pass) ||
|
AlternativePassword::check_md5(password, crypted_pass) ||
|
||||||
AlternativePassword::check_wordpress(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)
|
AlternativePassword::check_sha256(password, crypted_pass) ||
|
||||||
|
AlternativePassword::check_wbblite(password, crypted_pass)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_bcrypt(password, crypted_pass)
|
def self.check_bcrypt(password, crypted_pass)
|
||||||
@ -150,7 +152,13 @@ after_initialize do
|
|||||||
sha256 = Digest::SHA256.new
|
sha256 = Digest::SHA256.new
|
||||||
sha256.update password
|
sha256.update password
|
||||||
crypted_pass == sha256.hexdigest
|
crypted_pass == sha256.hexdigest
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.check_wbblite(password, crypted_pass)
|
||||||
|
salt, hash = crypted_pass.split(':', 2)
|
||||||
|
sha1 = Digest::SHA1.hexdigest(salt + Digest::SHA1.hexdigest(salt + Digest::SHA1.hexdigest(password)))
|
||||||
|
hash == sha1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ::User
|
class ::User
|
||||||
|
Loading…
Reference in New Issue
Block a user