Module: DataMapper::Is::Authenticatable::InstanceMethods

Defined in:
lib/dm-is-authenticatable/is/authenticatable.rb

Overview

Instance methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#passwordObject

The clear-text password



53
54
55
# File 'lib/dm-is-authenticatable/is/authenticatable.rb', line 53

def password
  @password
end

#password_confirmationObject

The confirmed clear-text password



56
57
58
# File 'lib/dm-is-authenticatable/is/authenticatable.rb', line 56

def password_confirmation
  @password_confirmation
end

Instance Method Details

#has_password?(submitted_password) ⇒ Boolean

Determines if the submitted password matches the encrypted_password.

Parameters:

  • submitted_password (String)

    The submitted password.

Returns:

  • (Boolean)

    Specifies whether the submitted password matches.

Since:

  • 0.2.0



95
96
97
98
99
100
101
# File 'lib/dm-is-authenticatable/is/authenticatable.rb', line 95

def has_password?()
  if password_required?
    self.encrypted_password == 
  else
    .nil? || .empty?
  end
end

#password_required?Boolean

Determines if a password is required for authentication.

Returns:

  • (Boolean)

    Specifies whether a password is required or not.

Since:

  • 0.2.0



80
81
82
# File 'lib/dm-is-authenticatable/is/authenticatable.rb', line 80

def password_required?
  !self.encrypted_password.nil?
end