Module: Faalis::Concerns::User::AuthDefinitions
- Included in:
- User
- Defined in:
- app/models/faalis/concerns/user/auth_definitions.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #admin? ⇒ Boolean
-
#confirmation_required? ⇒ Boolean
Confirmation not required when using omniauth.
- #full_name ⇒ Object
- #name ⇒ Object
-
#password_required? ⇒ Boolean
Omniauth users does not need password.
- #update_with_password(params, *options) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 4 def self.included(base) base.class_eval do # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable @@devise_options = ::Faalis::Engine. if Devise.omniauth_configs.any? devise :omniauthable, :omniauth_providers => Devise.omniauth_configs.keys end end base.extend ClassMethods end |
Instance Method Details
#admin? ⇒ Boolean
32 33 34 35 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 32 def admin? # TODO: Find a better way to 'admin?' groups.where(role: 'admin').exists? end |
#confirmation_required? ⇒ Boolean
Confirmation not required when using omniauth
38 39 40 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 38 def confirmation_required? super && identities.empty? end |
#full_name ⇒ Object
28 29 30 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 28 def full_name name end |
#name ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 19 def name if first_name or last_name "#{first_name} #{last_name}" else email end end |
#password_required? ⇒ Boolean
Omniauth users does not need password
51 52 53 54 55 56 57 58 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 51 def password_required? # TODO: nil? is not suitable for here we should use empty? or blink? if Devise.omniauth_configs.any? return (provider.nil? || password.nil?) && super else password.nil? && super end end |
#update_with_password(params, *options) ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/models/faalis/concerns/user/auth_definitions.rb', line 42 def update_with_password(params, *) if encrypted_password.blank? update_attributes(params, *) else super end end |