Module: Shield::Model::ClassMethods

Defined in:
lib/shield.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(username, password) ⇒ Object



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

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

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

#fetch(login) ⇒ Object

Raises:



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

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

#is_valid_password?(user, password) ⇒ Boolean

Returns:

  • (Boolean)


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

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