Module: Shield::Model

Defined in:
lib/shield/model.rb

Defined Under Namespace

Classes: FetchMissing

Instance Method Summary collapse

Instance Method Details

#authenticate(username, password) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/shield/model.rb', line 3

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

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

#fetch(login) ⇒ Object

Raises:



11
12
13
# File 'lib/shield/model.rb', line 11

def fetch()
  raise FetchMissing
end

#is_valid_password?(user, password) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/shield/model.rb', line 15

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