Module: Shield::Model::ClassMethods

Defined in:
lib/shield.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(username, password) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/shield.rb', line 78

def authenticate(username, password)
  user = fetch(username)

  if user and is_valid_password?(user, password)
    return user
  end
end

#fetch(login) ⇒ Object

Raises:



86
87
88
# File 'lib/shield.rb', line 86

def fetch()
  raise FetchMissing, "#{self}.fetch not implemented"
end

#is_valid_password?(user, password) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/shield.rb', line 90

def is_valid_password?(user, password)
  Shield::Password.check(password, user.crypted_password)
end