Sha256: 6208c20b132bda49073d8353b0e2e504c4c318c4b85fb942f67a483420103347
Contents?: true
Size: 839 Bytes
Versions: 12
Compression:
Stored size: 839 Bytes
Contents
module Clearance module PasswordStrategies module BCrypt require 'bcrypt' extend ActiveSupport::Concern def authenticated?(password) if encrypted_password.present? ::BCrypt::Password.new(encrypted_password) == password end end def password=(new_password) @password = new_password if new_password.present? self.encrypted_password = encrypt(new_password) end end private def encrypt(password) ::BCrypt::Password.create(password, cost: cost) end def cost if test_environment? ::BCrypt::Engine::MIN_COST else ::BCrypt::Engine::DEFAULT_COST end end def test_environment? defined?(::Rails) && ::Rails.env.test? end end end end
Version data entries
12 entries across 12 versions & 1 rubygems