Class: Cassy::Authenticators::Devise

Inherits:
Base
  • Object
show all
Defined in:
lib/cassy/authenticators/devise.rb

Class Method Summary collapse

Methods inherited from Base

configure, extra_attributes, extra_attributes_to_extract, setup, #validate

Class Method Details

.find_user(credentials) ⇒ Object



5
6
7
8
9
# File 'lib/cassy/authenticators/devise.rb', line 5

def self.find_user(credentials)
  # Find the user with the given email
  method = "find_by_#{Cassy.config[:username_field] || 'email'}"
  User.send(method, credentials[:username])
end

.validate(credentials) ⇒ Object



11
12
13
14
15
# File 'lib/cassy/authenticators/devise.rb', line 11

def self.validate(credentials)
  user = find_user(credentials)
  # Did we find a user, and is their password valid?
  user && user.valid_password?(credentials[:password])
end