Sha256: 020920d0242e5335bc8ab6c1e2d6726265c3e081f0b8c69375ba1653d1ff60dc
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
module Clearance module PasswordStrategies module BCryptMigrationFromSHA1 class BCryptUser include Clearance::PasswordStrategies::BCrypt def initialize(user) @user = user end delegate :encrypted_password, :encrypted_password=, to: :@user end class SHA1User include Clearance::PasswordStrategies::SHA1 def initialize(user) @user = user end delegate :salt, :salt=, :encrypted_password, :encrypted_password=, to: :@user end def authenticated?(password) authenticated_with_sha1?(password) || authenticated_with_bcrypt?(password) end def password=(new_password) BCryptUser.new(self).password = new_password end private def authenticated_with_bcrypt?(password) BCryptUser.new(self).authenticated? password end def authenticated_with_sha1?(password) if sha1_password? if SHA1User.new(self).authenticated? password self.password = password true end end end def sha1_password? self.encrypted_password =~ /^[a-f0-9]{40}$/ end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clearance-1.0.0.rc1 | lib/clearance/password_strategies/bcrypt_migration_from_sha1.rb |