Class: EasyAdmin::AdminUser

Inherits:
ApplicationRecord show all
Includes:
Permissions::UserExtensions, TwoFactorAuthentication
Defined in:
app/models/easy_admin/admin_user.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


40
41
42
# File 'app/models/easy_admin/admin_user.rb', line 40

def active?
  !locked_at.present?
end

#display_nameObject



32
33
34
# File 'app/models/easy_admin/admin_user.rb', line 32

def display_name
  full_name.present? ? full_name : email
end

#full_nameObject

Instance methods



28
29
30
# File 'app/models/easy_admin/admin_user.rb', line 28

def full_name
  "#{first_name} #{last_name}".strip
end

#initialsObject



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

Returns:

  • (Boolean)


44
45
46
# File 'app/models/easy_admin/admin_user.rb', line 44

def recently_active?
   &&  > 1.week.ago
end