Module: Spree::AdminUserMethods
- Extended by:
- ActiveSupport::Concern
- Includes:
- Actor, PrefixedId, RansackableAttributes, SignedIdAttachments, UserRoles
- Included in:
- AdminUser
- Defined in:
- app/models/concerns/spree/admin_user_methods.rb
Constant Summary collapse
- STATUSES =
%w[active locked deactivated].freeze
Constants included from RansackableAttributes
RansackableAttributes::RESTRICTED_AUDIENCES
Constants included from PrefixedId
Constants included from Actor
Instance Method Summary collapse
-
#active_sessions ⇒ ActiveRecord::Relation<Spree::RefreshToken>
Sessions that can still be refreshed, most recently used first.
- #can_be_deleted? ⇒ Boolean
-
#full_name ⇒ String
Returns the full name of the user.
-
#status ⇒ String
Whether the account can sign in.
Methods included from RansackableAttributes
restricted_audience?, scope_type_from_signature, signature_hidden?
Methods included from PrefixedId
#assign_attributes, decode_prefixed_id, #prefixed_id, prefixed_id?, #to_param
Methods included from Actor
Instance Method Details
#active_sessions ⇒ ActiveRecord::Relation<Spree::RefreshToken>
Sessions that can still be refreshed, most recently used first.
106 107 108 |
# File 'app/models/concerns/spree/admin_user_methods.rb', line 106 def active_sessions refresh_tokens.active.order(created_at: :desc) end |
#can_be_deleted? ⇒ Boolean
87 88 89 |
# File 'app/models/concerns/spree/admin_user_methods.rb', line 87 def can_be_deleted? Spree::Store.current.users.where.not(id: id).exists? end |
#full_name ⇒ String
Returns the full name of the user
112 113 114 |
# File 'app/models/concerns/spree/admin_user_methods.rb', line 112 def full_name name&.full end |
#status ⇒ String
Whether the account can sign in. Duck-typed: a custom admin user class may lack deactivation or lockout.
94 95 96 97 98 99 100 101 102 |
# File 'app/models/concerns/spree/admin_user_methods.rb', line 94 def status if try(:deactivated?) 'deactivated' elsif try(:locked?) 'locked' else 'active' end end |