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.
22 23 24 |
# File 'app/models/edge_auth/identity.rb', line 22 def password @password end |
#updating_password ⇒ Object
Returns the value of attribute updating_password.
22 23 24 |
# File 'app/models/edge_auth/identity.rb', line 22 def updating_password @updating_password end |
Class Method Details
.authenticate(email, submitted_password) ⇒ Object
56 57 58 59 60 |
# File 'app/models/edge_auth/identity.rb', line 56 def self.authenticate(email, submitted_password) user = Identity.first(conditions: {email: email}) 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
62 63 64 65 66 |
# File 'app/models/edge_auth/identity.rb', line 62 def self.authenticate_with_salt(id, ) return nil if id.nil? user = Identity.first(conditions: {_id: id}) (user && user.salt == ) ? user : nil end |
Instance Method Details
#activated? ⇒ Boolean
68 69 70 71 72 73 |
# File 'app/models/edge_auth/identity.rb', line 68 def activated? if self.activated_at == nil return false end return true end |
#do_activate ⇒ Object
87 88 89 90 |
# File 'app/models/edge_auth/identity.rb', line 87 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.
52 53 54 |
# File 'app/models/edge_auth/identity.rb', line 52 def has_password?(submitted_password) encrypted_password == encrypt(submitted_password) end |
#reset_password ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/models/edge_auth/identity.rb', line 79 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
75 76 77 |
# File 'app/models/edge_auth/identity.rb', line 75 def reset_password_expired? return self.reset_password_mail_sent_at < 1.day.ago end |