module Authpwn::UserExtensions::PasswordField

Augments the User model with a password virtual attribute.

Public Instance Methods

password() click to toggle source

The password from the user's Password credential, or nil.

Returns nil if this user has no Password credential.

# File lib/authpwn_rails/user_extensions/password_field.rb, line 27
def password
  credential = self.password_credential
  credential && credential.password
end
password=(new_password) click to toggle source

Sets the password on the user's Password credential.

Creates a new Credentials::Password instance if necessary.

# 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() click to toggle source

The password_confirmation from the user's Password credential, or nil.

Returns nil if this user has no Password credential.

# 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) click to toggle source

Sets the password on the user's Password credential.

Creates a new Credentials::Password instance if necessary.

# 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() click to toggle source

Credentials::Password instance associated with this user.

# File lib/authpwn_rails/user_extensions/password_field.rb, line 20
def password_credential
  credentials.find { |c| c.instance_of?(Credentials::Password) }
end