<% devices = @user.otp_devices.reload %> <% default_device = @user.otp_devices.get_default %>
<%= render ::Components::OnOffStatusComponent.new({ is_on: default_device.present?, on_text: t('two_factor_authentication.label_2fa_enabled'), on_description: t('two_factor_authentication.admin.text_2fa_enabled'), off_text: t('two_factor_authentication.label_2fa_disabled'), off_description: t('two_factor_authentication.admin.text_2fa_disabled') })%>
<% if default_device.present? %> <%= render(AttributeGroups::AttributeGroupComponent.new) do |component| component.with_attribute(key: t('two_factor_authentication.label_default_device'), value: default_device.identifier) if default_device.phone_number.present? component.with_attribute(key: ::TwoFactorAuthentication::Device::Sms.human_attribute_name(:phone_number), value: default_device.phone_number) end end %> <% end %>
<%= toolbar title: t('two_factor_authentication.label_devices') do %> <% unless devices.empty? %>
  • <%= link_to delete_all_user_2fa_devices_path(@user), method: :post, data: { confirm: t('two_factor_authentication.admin.delete_all_are_you_sure') }, class: "button -danger" do %> <%= op_icon 'button--icon icon-delete' %> <%= t 'two_factor_authentication.admin.button_delete_all_devices' %> <% end %>
  • <% end %> <% if ::OpenProject::TwoFactorAuthentication::TokenStrategyManager.admin_register_sms_strategy.present? %>
  • <%= link_to new_user_2fa_device_path(@user, type: :sms), class: 'button -primary' do %> <%= op_icon 'button--icon icon-add' %> <%= t 'two_factor_authentication.admin.button_register_mobile_phone_for_user' %> <% end %>
  • <% end %> <% end %> <%= render ::TwoFactorAuthentication::Devices::TableComponent.new(rows: devices, admin_table: true || @user != User.current) %>