Class: EasyAdmin::AdminUser
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- EasyAdmin::AdminUser
- Defined in:
- app/models/easy_admin/admin_user.rb
Class Method Summary collapse
-
.create_default_admin! ⇒ Object
Class methods.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #display_name ⇒ Object
-
#full_name ⇒ Object
Instance methods.
- #initials ⇒ Object
- #recently_active? ⇒ Boolean
Methods included from TwoFactorAuthentication
available?, #backup_codes_remaining, #current_otp, #disable_two_factor!, #enable_two_factor!, #generate_backup_codes!, #generate_otp_secret!, #invalidate_backup_code!, #provisioning_uri, #qr_code_svg, #should_enable_two_factor?, #two_factor_available?, #two_factor_enabled?, #two_factor_required?, #validate_and_consume_otp!, #validate_backup_code!
Methods included from Permissions::UserExtensions
#calculate_permissions, #clear_permissions_cache!, #has_permission?, #has_role?, #remove_permission, #roles_for_context, #set_permission
Class Method Details
.create_default_admin! ⇒ Object
Class methods
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/easy_admin/admin_user.rb', line 49 def self.create_default_admin! return if exists? create!( email: "[email protected]", password: "password", password_confirmation: "password", first_name: "Admin", last_name: "User", confirmed_at: Time.current ) end |
Instance Method Details
#active? ⇒ Boolean
40 41 42 |
# File 'app/models/easy_admin/admin_user.rb', line 40 def active? !locked_at.present? end |
#display_name ⇒ Object
32 33 34 |
# File 'app/models/easy_admin/admin_user.rb', line 32 def display_name full_name.present? ? full_name : email end |
#full_name ⇒ Object
Instance methods
28 29 30 |
# File 'app/models/easy_admin/admin_user.rb', line 28 def full_name "#{first_name} #{last_name}".strip end |
#initials ⇒ Object
36 37 38 |
# File 'app/models/easy_admin/admin_user.rb', line 36 def initials "#{first_name&.first}#{last_name&.first}".upcase end |
#recently_active? ⇒ Boolean
44 45 46 |
# File 'app/models/easy_admin/admin_user.rb', line 44 def recently_active? last_sign_in_at && last_sign_in_at > 1.week.ago end |