Module: Janus::Models::DatabaseAuthenticatable::ClassMethods

Defined in:
lib/janus/models/database_authenticatable.rb

Instance Method Summary collapse

Instance Method Details

#find_for_database_authentication(params) ⇒ Object



109
110
111
112
# File 'lib/janus/models/database_authenticatable.rb', line 109

def find_for_database_authentication(params)
  params = params.reject { |k,v| !authentication_keys.include?(k.to_sym) }
  where(params).first
end

#find_for_password_reset(token) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/janus/models/database_authenticatable.rb', line 114

def find_for_password_reset(token)
  user = find_by_reset_password_token(token) unless token.blank?

  if user && user.reset_password_sent_at < 2.days.ago
    user.reset_password_token = user.reset_password_sent_at = nil
    user.save
    user = nil
  end

  user
end