Module: Merb::Authentication::Mixins::BCryptUser::InstanceMethods

Defined in:
lib/merb-auth-more/mixins/bcrypt_user.rb

Instance Method Summary collapse

Instance Method Details

#authenticated?(password) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/merb-auth-more/mixins/bcrypt_user.rb', line 49

def authenticated?(password)
  bcrypt_password == password
end

#bcrypt_passwordObject



53
54
55
# File 'lib/merb-auth-more/mixins/bcrypt_user.rb', line 53

def bcrypt_password
  @bcrypt_password ||=  BCrypt::Password.new(crypted_password)
end

#encrypt_passwordObject



61
62
63
64
65
# File 'lib/merb-auth-more/mixins/bcrypt_user.rb', line 61

def encrypt_password
  return if password.blank?
  cost =  Merb::Plugins.config[:"merb-auth"][:bcrypt_cost] || BCrypt::Engine::DEFAULT_COST
  self.crypted_password =  BCrypt::Password.create(password, :cost => cost)
end

#password_required?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/merb-auth-more/mixins/bcrypt_user.rb', line 57

def password_required?
  crypted_password.blank? || !password.blank?
end