Module: Authorizme::ActsAsAuthorizme::InstanceMethodsOnActivation
- Defined in:
- lib/authorizme/acts_as_authorizme.rb
Instance Method Summary collapse
-
#authenticate(unencrypted_password) ⇒ Object
Returns self if the password is correct, otherwise false.
- #has_not_provider? ⇒ Boolean
- #has_synchronize_request? ⇒ Boolean
- #need_check_password? ⇒ Boolean
- #on_logged_in ⇒ Object
-
#password=(unencrypted_password) ⇒ Object
Encrypts the password into the password_digest attribute.
- #password_will_be_update_in_this_request ⇒ Object
- #send_password_reset ⇒ Object
- #set_new_password_reset_token ⇒ Object
- #synchronize(other_user) ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#authenticate(unencrypted_password) ⇒ Object
Returns self if the password is correct, otherwise false.
99 100 101 102 103 104 105 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 99 def authenticate(unencrypted_password) if password_digest && BCrypt::Password.new(password_digest) == unencrypted_password self else false end end |
#has_not_provider? ⇒ Boolean
115 116 117 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 115 def has_not_provider? !self.has_provider end |
#has_synchronize_request? ⇒ Boolean
127 128 129 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 127 def has_synchronize_request? self.synchronize_requests.status_new.any? end |
#need_check_password? ⇒ Boolean
119 120 121 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 119 def need_check_password? self.password_will_be_update end |
#on_logged_in ⇒ Object
142 143 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 142 def on_logged_in end |
#password=(unencrypted_password) ⇒ Object
Encrypts the password into the password_digest attribute.
108 109 110 111 112 113 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 108 def password=(unencrypted_password) @password = unencrypted_password unless unencrypted_password.blank? self.password_digest = BCrypt::Password.create(unencrypted_password) end end |
#password_will_be_update_in_this_request ⇒ Object
123 124 125 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 123 def password_will_be_update_in_this_request self.password_will_be_update = true end |
#send_password_reset ⇒ Object
145 146 147 148 149 150 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 145 def send_password_reset set_new_password_reset_token self.password_reset_sent_at = Time.zone.now self.save! send_password_reset_notification end |
#set_new_password_reset_token ⇒ Object
152 153 154 155 156 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 152 def set_new_password_reset_token begin self.password_reset_token = SecureRandom.urlsafe_base64 end while User.exists?(:password_reset_token => self.password_reset_token) end |
#synchronize(other_user) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 131 def synchronize other_user other_user.providers.each do |other_provider| other_provider.update_attributes({user: self}) end on_synchronized other_user end |
#to_s ⇒ Object
138 139 140 |
# File 'lib/authorizme/acts_as_authorizme.rb', line 138 def to_s "#{self.first_name} #{self.last_name}" end |