Class: Admin::User
Class Method Summary
collapse
Instance Method Summary
collapse
#otp, #requires_otp?
#archive, #archive!, #archived=, #archived?, #restore, #restore!
Class Method Details
.model_name ⇒ Object
8
9
10
|
# File 'app/models/admin/user.rb', line 8
def self.model_name
ActiveModel::Name.new(self, nil, "AdminUser")
end
|
Instance Method Details
#last_active_at ⇒ ActiveSupport::TimeWithZone?
Describe the last time the user signed in or out. For self-reflection, excludes the current session.
87
88
89
|
# File 'app/models/admin/user.rb', line 87
def last_active_at
[last_sign_in_at, last_sign_out_at].compact.max
end
|
#passkey? ⇒ Boolean
Also known as:
passkey
79
80
81
|
# File 'app/models/admin/user.rb', line 79
def passkey?
credentials.any?
end
|
#password_login ⇒ Object
98
99
100
101
102
103
104
105
106
|
# File 'app/models/admin/user.rb', line 98
def password_login
if password_digest.blank?
:none
elsif otp_secret.nil?
:password_only
else
:mfa
end
end
|
#previous_active_at(current_session = Koi::Current.session) ⇒ ActiveSupport::TimeWithZone?
Describe the last time the user signed in or out, excluding the current session (for self).
94
95
96
|
# File 'app/models/admin/user.rb', line 94
def previous_active_at(current_session = Koi::Current.session)
[last_sign_out_at, sessions.where.not(id: current_session.id).maximum(:created_at)].compact.max
end
|
#to_s ⇒ Object
108
109
110
|
# File 'app/models/admin/user.rb', line 108
def to_s
name
end
|