Class: Account
- Inherits:
-
Object
- Object
- Account
- Includes:
- Mongoid::Document
- Defined in:
- lib/bolton_cms/models/account.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_confirmation ⇒ Object
Returns the value of attribute password_confirmation.
Class Method Summary collapse
-
.authenticate(email, password) ⇒ Object
This method is for authentication purpose.
-
.find_by_id(id) ⇒ Object
This method is used by AuthenticationHelper.
Instance Method Summary collapse
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/bolton_cms/models/account.rb', line 7 def password @password end |
#password_confirmation ⇒ Object
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) account = where(email: /#{Regexp.escape(email)}/i).first if email.present? account && account.has_password?(password) ? account : 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
41 42 43 |
# File 'lib/bolton_cms/models/account.rb', line 41 def has_password?(password) ::BCrypt::Password.new(crypted_password) == password end |