From 1e6bd8f9bcd6fd05bc6bae6331be363d56d3fcf1 Mon Sep 17 00:00:00 2001 From: DiscourseHosting Date: Thu, 2 Jul 2015 17:35:36 -0400 Subject: [PATCH] Catch exception; add sha256 support --- plugin.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/plugin.rb b/plugin.rb index ab02832..eca6e3d 100644 --- a/plugin.rb +++ b/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