Class: EdgeAuth::Identity
- Inherits:
-
Object
- Object
- EdgeAuth::Identity
- Includes:
- Mongoid::Document, Mongoid::EdgeStateMachine, Mongoid::Timestamps
- Defined in:
- app/models/edge_auth/identity.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
Returns the value of attribute password.
-
#updating_password ⇒ Object
Returns the value of attribute updating_password.
Class Method Summary collapse
Instance Method Summary collapse
- #activated? ⇒ Boolean
- #do_activate ⇒ Object
-
#has_password?(submitted_password) ⇒ Boolean
Return true if the user’s password matches the submitted password.
- #reset_password ⇒ Object
- #reset_password_expired? ⇒ Boolean
Instance Attribute Details
#password ⇒ Object
Returns the value of attribute password.
19 20 21 |
# File 'app/models/edge_auth/identity.rb', line 19 def password @password end |
#updating_password ⇒ Object
Returns the value of attribute updating_password.
19 20 21 |
# File 'app/models/edge_auth/identity.rb', line 19 def updating_password @updating_password end |
Class Method Details
.authenticate(email, submitted_password) ⇒ Object
53 54 55 56 57 |
# File 'app/models/edge_auth/identity.rb', line 53 def self.authenticate(email, submitted_password) user = Identity.where(email: email).first return nil if user.nil? or user.state == "blocked" return user if user.has_password?(submitted_password) end |
.authenticate_with_salt(id, cookie_salt) ⇒ Object
59 60 61 62 63 |
# File 'app/models/edge_auth/identity.rb', line 59 def self.authenticate_with_salt(id, ) return nil if id.nil? user = Identity.where(_id: id).first (user && user.salt == ) ? user : nil end |
Instance Method Details
#activated? ⇒ Boolean
65 66 67 68 69 70 |
# File 'app/models/edge_auth/identity.rb', line 65 def activated? if self.activated_at == nil return false end return true end |
#do_activate ⇒ Object
84 85 86 87 |
# File 'app/models/edge_auth/identity.rb', line 84 def do_activate self.activated_at = Time.now.utc self.save! end |
#has_password?(submitted_password) ⇒ Boolean
Return true if the user’s password matches the submitted password.
49 50 51 |
# File 'app/models/edge_auth/identity.rb', line 49 def has_password?(submitted_password) encrypted_password == encrypt(submitted_password) end |
#reset_password ⇒ Object
76 77 78 79 80 81 82 |
# File 'app/models/edge_auth/identity.rb', line 76 def reset_password self.password_reset_code = generate_token self.reset_password_mail_sent_at = Time.now.utc self.save!(validate: false) # we send the reset password mail #UserMailer.reset_password(self).deliver end |
#reset_password_expired? ⇒ Boolean
72 73 74 |
# File 'app/models/edge_auth/identity.rb', line 72 def reset_password_expired? return self.reset_password_mail_sent_at < 1.day.ago end |