Module: Authpwn::UserExtensions::PasswordField
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/authpwn_rails/user_extensions/password_field.rb
Overview
Augments the User model with a password virtual attribute.
Instance Method Summary collapse
-
#password ⇒ Object
The password from the user’s Password credential, or nil.
-
#password=(new_password) ⇒ Object
Sets the password on the user’s Password credential.
-
#password_confirmation ⇒ Object
The password_confirmation from the user’s Password credential, or nil.
-
#password_confirmation=(new_password_confirmation) ⇒ Object
Sets the password on the user’s Password credential.
-
#password_credential ⇒ Object
Credentials::Password instance associated with this user.
Instance Method Details
#password ⇒ Object
The password from the user’s Password credential, or nil.
Returns nil if this user has no Password credential.
27 28 29 30 |
# File 'lib/authpwn_rails/user_extensions/password_field.rb', line 27 def password credential = self.password_credential credential && credential.password end |
#password=(new_password) ⇒ Object
Sets the password on the user’s Password credential.
Creates a new Credentials::Password instance if necessary.
43 44 45 46 47 48 49 50 |
# File 'lib/authpwn_rails/user_extensions/password_field.rb', line 43 def password=(new_password) if credential = self.password_credential credential.password = new_password else credentials << Credentials::Password.new(password: new_password) end new_password end |
#password_confirmation ⇒ Object
The password_confirmation from the user’s Password credential, or nil.
Returns nil if this user has no Password credential.
35 36 37 38 |
# File 'lib/authpwn_rails/user_extensions/password_field.rb', line 35 def password_confirmation credential = self.password_credential credential && credential.password_confirmation end |
#password_confirmation=(new_password_confirmation) ⇒ Object
Sets the password on the user’s Password credential.
Creates a new Credentials::Password instance if necessary.
55 56 57 58 59 60 61 62 63 |
# File 'lib/authpwn_rails/user_extensions/password_field.rb', line 55 def password_confirmation=(new_password_confirmation) if credential = self.password_credential credential.password_confirmation = new_password_confirmation else credentials << Credentials::Password.new(password_confirmation: new_password_confirmation) end new_password_confirmation end |
#password_credential ⇒ Object
Credentials::Password instance associated with this user.
20 21 22 |
# File 'lib/authpwn_rails/user_extensions/password_field.rb', line 20 def password_credential credentials.find { |c| c.instance_of?(Credentials::Password) } end |