Class: Gaku::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gaku::User
- Defined in:
- app/models/gaku/user.rb
Instance Attribute Summary collapse
-
#login ⇒ Object
Returns the value of attribute login.
Class Method Summary collapse
-
.find_first_by_auth_conditions(warden_conditions) ⇒ Object
Override Devise::Models::Authenticatable#find_first_by_auth_conditions so login can be authenticated against username or email.
Instance Method Summary collapse
Instance Attribute Details
#login ⇒ Object
Returns the value of attribute login.
11 12 13 |
# File 'app/models/gaku/user.rb', line 11 def login @login end |
Class Method Details
.find_first_by_auth_conditions(warden_conditions) ⇒ Object
Override Devise::Models::Authenticatable#find_first_by_auth_conditions so login can be authenticated against username or email
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/gaku/user.rb', line 25 def self.find_first_by_auth_conditions(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 |
Instance Method Details
#role?(role) ⇒ Boolean
38 39 40 |
# File 'app/models/gaku/user.rb', line 38 def role?(role) roles.where(name: role.to_s.camelize).any? end |
#to_s ⇒ Object
19 20 21 |
# File 'app/models/gaku/user.rb', line 19 def to_s username end |