2014-04-10 20:03:08 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: admin_users
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# email :string(255) default(""), not null
|
|
|
|
# encrypted_password :string(255) default(""), not null
|
|
|
|
# reset_password_token :string(255)
|
|
|
|
# reset_password_sent_at :datetime
|
|
|
|
# remember_created_at :datetime
|
|
|
|
# sign_in_count :integer default(0), not null
|
|
|
|
# current_sign_in_at :datetime
|
|
|
|
# last_sign_in_at :datetime
|
|
|
|
# current_sign_in_ip :string(255)
|
|
|
|
# last_sign_in_ip :string(255)
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
#
|
|
|
|
|
2014-03-22 18:21:45 +01:00
|
|
|
class AdminUser < ActiveRecord::Base
|
|
|
|
# Include default devise modules. Others available are:
|
|
|
|
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
|
|
|
|
devise :database_authenticatable,
|
|
|
|
:recoverable, :rememberable, :trackable, :validatable
|
|
|
|
|
|
|
|
attr_accessor :login
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def self.find_for_database_authentication(warden_conditions)
|
|
|
|
conditions = warden_conditions.dup
|
|
|
|
login = conditions.delete(:login)
|
|
|
|
where(conditions).where(["lower(email) = :value", { :value => login.strip.downcase }]).first
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|