Sha256: 7119ea826fabc062b2db206416f53a777b24896db436c3ec299387631fcd0b3f

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'active_support/concern'

module ThecoreUiCommonsUser
    extend ActiveSupport::Concern
    
    included do
        devise :database_authenticatable, :trackable, :validatable, :rememberable, :timeoutable, timeout_in: 30.minutes, authentication_keys: [:login]
        
        attr_writer :login
        
        def login
            @login || self.username || self.email
        end
        # Use login
        def self.find_first_by_auth_conditions(warden_conditions)
            puts "################################ VIENE USATO? #####################################################"
            conditions = warden_conditions.dup
            if login = conditions.delete(:login)
                where(conditions.to_h).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
            elsif conditions.has_key?(:username) || conditions.has_key?(:email)
                # Case insensitive login
                conditions[:email].downcase! if conditions[:email]
                conditions[:username].downcase! if conditions[:username]
                where(conditions.to_h).first
            end
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thecore_ui_commons-2.1.8 lib/concerns/thecore_ui_commons_user.rb
thecore_ui_commons-2.1.7 lib/concerns/thecore_ui_commons_user.rb