module DataMapper::Is::Authenticatable::InstanceMethods

Instance methods.

Attributes

password[R]

The clear-text password

password_confirmation[RW]

The confirmed clear-text password

Public Instance Methods

has_password?(submitted_password) click to toggle source

Determines if the submitted password matches the ‘encrypted_password`.

@param [String] submitted_password

The submitted password.

@return [Boolean]

Specifies whether the submitted password matches.

@since 0.2.0

# File lib/dm-is-authenticatable/is/authenticatable.rb, line 95
def has_password?(submitted_password)
  if password_required?
    self.encrypted_password == submitted_password
  else
    submitted_password.nil? || submitted_password.empty?
  end
end
password=(new_password) click to toggle source

Updates the password of the resource.

@param [String] new_password

The new password for the resource.

@return [String]

The new password of the resource.
# File lib/dm-is-authenticatable/is/authenticatable.rb, line 67
def password=(new_password)
  self.encrypted_password = new_password
  @password = new_password
end
password_required?() click to toggle source

Determines if a password is required for authentication.

@return [Boolean]

Specifies whether a password is required or not.

@since 0.2.0

# File lib/dm-is-authenticatable/is/authenticatable.rb, line 80
def password_required?
  !self.encrypted_password.nil?
end