Class: EasyAdmin::TwoFactor::SetupComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/easy_admin/two_factor/setup_component.rb

Instance Method Summary collapse

Methods inherited from BaseComponent

#easy_admin_url_helpers, #helpers, #rails_url_helpers

Methods included from Permissions::Component

#current_user_can?, #current_user_has_role?, #if_can, #if_has_role, #permission_attrs, #permission_button, #permission_case, #permission_classes, #permission_field, #permission_link, #unless_can, #unless_has_role

Methods included from FieldsHelper

#field_component, #render_field

Methods included from DashboardsHelper

#delta_badge_classes, #metric_value_classes, #render_card, #sparkline_color, #sparkline_points, #trend_direction, #trend_icon, #trend_indicator_classes

Constructor Details

#initialize(user:) ⇒ SetupComponent

Returns a new instance of SetupComponent.



4
5
6
# File 'app/components/easy_admin/two_factor/setup_component.rb', line 4

def initialize(user:)
  @user = user
end

Instance Method Details

#view_templateObject



8
9
10
11
12
13
14
15
16
# File 'app/components/easy_admin/two_factor/setup_component.rb', line 8

def view_template
  return render_unavailable unless @user.two_factor_available?
  
  if @user.otp_secret.blank?
    render_initial_setup
  else
    render_verification_step
  end
end