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



107
108
109
110
# File 'lib/janus/models/database_authenticatable.rb', line 107

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



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

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