Guest User

Untitled

a guest
Jan 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. ## auth method
  2. #
  3. def User.authenticate(*args)
  4. options = args.extract_options!.to_options!
  5. email = args.shift || options[:email]
  6. password = args.shift || options[:password]
  7.  
  8. return nil if email.blank?
  9.  
  10. user = User.where(:email => email.strip.downcase).first
  11.  
  12. return nil if user.blank?
  13. return nil if user.password.blank?
  14.  
  15. user.password == password ? user : false
  16. end
Add Comment
Please, Sign In to add comment