Sha256: f7a891337e3451cc1baf15afd9c32a609290596d5d973438cefdaa9e74c13755
Contents?: true
Size: 951 Bytes
Versions: 28
Compression:
Stored size: 951 Bytes
Contents
class User < ActiveRecord::Base include Authorizable # Include default devise modules. Others available are: # :registerable, :confirmable, :lockable and :omniauthable # Virtual attribute for authenticating by either username or email attr_accessor :login devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :timeoutable, :omniauthable validates :username, presence: true, uniqueness: { scope: :provider, case_sensitive: false } def display_name fullname.presence || username end # Devise method overridden to allow sign in with email or username def self.find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup login = conditions.delete(:login) if login where(conditions).where(['lower(username) = :value OR lower(email) = :value', { value: login.downcase }]).first else where(conditions).first end end end
Version data entries
28 entries across 28 versions & 1 rubygems