Class: User

Inherits:
ApplicationRecord
  • Object
show all
Includes:
Authorizable
Defined in:
app/models/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authorizable

#is?, #roles, #roles=

Instance Attribute Details

#loginObject

Virtual attribute for authenticating by either username or email



7
8
9
# File 'app/models/user.rb', line 7

def 
  @login
end

Class Method Details

.find_for_database_authentication(warden_conditions) ⇒ Object

Devise method overridden to allow sign in with email or username



19
20
21
22
23
24
25
26
27
# File 'app/models/user.rb', line 19

def self.find_for_database_authentication(warden_conditions)
  conditions = warden_conditions.dup
   = conditions.delete(:login)
  if 
    where(conditions).where(['lower(username) = :value OR lower(email) = :value', { value: .downcase }]).first
  else
    where(conditions).first
  end
end

Instance Method Details

#display_nameObject



14
15
16
# File 'app/models/user.rb', line 14

def display_name
  fullname.presence || username
end

#ldap_user?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/user.rb', line 29

def ldap_user?
  provider == 'ldap'
end