Class: Account

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
lib/bolton_cms/models/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/bolton_cms/models/account.rb', line 7

def password
  @password
end

#password_confirmationObject

Returns the value of attribute password_confirmation.



7
8
9
# File 'lib/bolton_cms/models/account.rb', line 7

def password_confirmation
  @password_confirmation
end

Class Method Details

.authenticate(email, password) ⇒ Object

This method is for authentication purpose



29
30
31
32
# File 'lib/bolton_cms/models/account.rb', line 29

def self.authenticate(email, password)
   = where(email: /#{Regexp.escape(email)}/i).first if email.present?
   && .has_password?(password) ?  : nil
end

.find_by_id(id) ⇒ Object

This method is used by AuthenticationHelper



37
38
39
# File 'lib/bolton_cms/models/account.rb', line 37

def self.find_by_id(id)
  find(id) rescue nil
end

Instance Method Details

#has_password?(password) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/bolton_cms/models/account.rb', line 41

def has_password?(password)
  ::BCrypt::Password.new(crypted_password) == password
end