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

PrefixedId::SQIDS

Constants included from Actor

Spree::Actor::BUILT_IN_KINDS

Instance Method Summary collapse

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

#actor_kind, #actor_label

Instance Method Details

#active_sessions ⇒ ActiveRecord::Relation<Spree::RefreshToken>

Sessions that can still be refreshed, most recently used first.

Returns:



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

Returns:

  • (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

Returns:

  • (String)


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.

Returns:

  • (String) —

    active, locked or deactivated



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