debian-mirror-gitlab/app/views/profiles/two_factor_auths/show.html.haml

120 lines
6 KiB
Text
Raw Normal View History

2019-09-04 21:01:54 +05:30
- page_title _('Two-Factor Authentication'), _('Account')
- add_to_breadcrumbs(_('Two-Factor Authentication'), profile_account_path)
2017-09-10 17:25:29 +05:30
- @content_class = "limit-container-width" unless fluid_layout
2020-11-24 15:15:51 +05:30
- webauthn_enabled = Feature.enabled?(:webauthn)
2017-09-10 17:25:29 +05:30
.js-two-factor-auth{ 'data-two-factor-skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path }
2020-07-28 23:09:34 +05:30
.row.gl-mt-3
2017-09-10 17:25:29 +05:30
.col-lg-4
2020-06-23 00:09:42 +05:30
%h4.gl-mt-0
2019-09-04 21:01:54 +05:30
= _('Register Two-Factor Authenticator')
%p
2019-09-04 21:01:54 +05:30
= _('Use an one time password authenticator on your mobile device or computer to enable two-factor authentication (2FA).')
2017-09-10 17:25:29 +05:30
.col-lg-8
- if current_user.two_factor_otp_enabled?
2018-03-17 18:26:18 +05:30
%p
2019-09-04 21:01:54 +05:30
= _("You've already enabled two-factor authentication using one time password authenticators. In order to register a different device, you must first disable two-factor authentication.")
2018-11-18 11:00:15 +05:30
%p
2019-09-04 21:01:54 +05:30
= _('If you lose your recovery codes you can generate new ones, invalidating all previous codes.')
2018-11-18 11:00:15 +05:30
%div
2019-09-04 21:01:54 +05:30
= link_to _('Disable two-factor authentication'), profile_two_factor_auth_path,
2018-03-17 18:26:18 +05:30
method: :delete,
2020-11-24 15:15:51 +05:30
data: { confirm: webauthn_enabled ? _('Are you sure? This will invalidate your registered applications and U2F / WebAuthn devices.') : _('Are you sure? This will invalidate your registered applications and U2F devices.') },
2021-01-03 14:25:43 +05:30
class: 'gl-button btn btn-danger gl-mr-3'
2018-11-18 11:00:15 +05:30
= form_tag codes_profile_two_factor_auth_path, {style: 'display: inline-block', method: :post} do |f|
2019-09-04 21:01:54 +05:30
= submit_tag _('Regenerate recovery codes'), class: 'btn'
2018-11-18 11:00:15 +05:30
2017-09-10 17:25:29 +05:30
- else
%p
2019-09-04 21:01:54 +05:30
- help_link_start = '<a href="%{url}" target="_blank">' % { url: help_page_path('user/profile/account/two_factor_authentication') }
2020-01-01 13:55:28 +05:30
- register_2fa_token = _('Install a soft token authenticator like %{free_otp_link} or Google Authenticator from your application repository and use that app to scan this QR code. More information is available in the %{help_link_start}documentation%{help_link_end}.') % { free_otp_link:'<a href="https://freeotp.github.io/">FreeOTP</a>', help_link_start:help_link_start, help_link_end:'</a>' }
2019-09-04 21:01:54 +05:30
= register_2fa_token.html_safe
2020-10-24 23:57:45 +05:30
.row.gl-mb-3
2017-09-10 17:25:29 +05:30
.col-md-4
= raw @qr_code
.col-md-8
.account-well
2020-06-23 00:09:42 +05:30
%p.gl-mt-0.gl-mb-0
2019-09-04 21:01:54 +05:30
= _("Can't scan the code?")
2020-06-23 00:09:42 +05:30
%p.gl-mt-0.gl-mb-0
2019-09-04 21:01:54 +05:30
= _('To add the entry manually, provide the following details to the application on your phone.')
2020-06-23 00:09:42 +05:30
%p.gl-mt-0.gl-mb-0
2019-09-04 21:01:54 +05:30
= _('Account: %{account}') % { account: @account_string }
2020-07-28 23:09:34 +05:30
%p.gl-mt-0.gl-mb-0{ data: { qa_selector: 'otp_secret_content' } }
2019-09-04 21:01:54 +05:30
= _('Key: %{key}') %{ key: current_user.otp_secret.scan(/.{4}/).join(' ') }
2017-09-10 17:25:29 +05:30
%p.two-factor-new-manual-content
2019-09-04 21:01:54 +05:30
= _('Time based: Yes')
2017-09-10 17:25:29 +05:30
= form_tag profile_two_factor_auth_path, method: :post do |f|
- if @error
2020-11-24 15:15:51 +05:30
.gl-alert.gl-alert-danger.gl-mb-5
2017-09-10 17:25:29 +05:30
= @error
.form-group
2019-09-04 21:01:54 +05:30
= label_tag :pin_code, _('Pin code'), class: "label-bold"
2020-07-28 23:09:34 +05:30
= text_field_tag :pin_code, nil, class: "form-control", required: true, data: { qa_selector: 'pin_code_field' }
.gl-mt-3
2021-01-03 14:25:43 +05:30
= submit_tag _('Register with two-factor app'), class: 'gl-button btn btn-success', data: { qa_selector: 'register_2fa_app_button' }
2017-09-10 17:25:29 +05:30
%hr
2020-07-28 23:09:34 +05:30
.row.gl-mt-3
2017-09-10 17:25:29 +05:30
.col-lg-4
2020-06-23 00:09:42 +05:30
%h4.gl-mt-0
2020-11-24 15:15:51 +05:30
- if webauthn_enabled
= _('Register WebAuthn Device')
- else
= _('Register Universal Two-Factor (U2F) Device')
2017-09-10 17:25:29 +05:30
%p
2021-01-03 14:25:43 +05:30
= _('Set up a hardware device as a second factor to sign in.')
2017-09-10 17:25:29 +05:30
%p
2020-11-24 15:15:51 +05:30
- if webauthn_enabled
2021-01-03 14:25:43 +05:30
= _("Not all browsers support WebAuthn. Therefore, we require that you set up a two-factor authentication app first. That way you'll always be able to sign in - even from an unsupported browser.")
2020-11-24 15:15:51 +05:30
- else
2021-01-03 14:25:43 +05:30
= _("Not all browsers support U2F devices. Therefore, we require that you set up a two-factor authentication app first. That way you'll always be able to sign in - even when you're using an unsupported browser.")
2017-09-10 17:25:29 +05:30
.col-lg-8
2020-11-24 15:15:51 +05:30
- registration = webauthn_enabled ? @webauthn_registration : @u2f_registration
- if registration.errors.present?
= form_errors(registration)
- if webauthn_enabled
= render "authentication/register", target_path: create_webauthn_profile_two_factor_auth_path
- else
= render "authentication/register", target_path: create_u2f_profile_two_factor_auth_path
2017-09-10 17:25:29 +05:30
%hr
2016-09-13 17:45:13 +05:30
2019-09-04 21:01:54 +05:30
%h5
2020-11-24 15:15:51 +05:30
- if webauthn_enabled
= _('WebAuthn Devices (%{length})') % { length: @registrations.length }
- else
= _('U2F Devices (%{length})') % { length: @registrations.length }
2016-09-13 17:45:13 +05:30
2020-11-24 15:15:51 +05:30
- if @registrations.present?
2017-09-10 17:25:29 +05:30
.table-responsive
%table.table.table-bordered.u2f-registrations
%colgroup
%col{ width: "50%" }
%col{ width: "30%" }
%col{ width: "20%" }
%thead
2016-09-13 17:45:13 +05:30
%tr
2019-09-04 21:01:54 +05:30
%th= _('Name')
%th= s_('2FADevice|Registered On')
2017-09-10 17:25:29 +05:30
%th
%tbody
2020-11-24 15:15:51 +05:30
- @registrations.each do |registration|
2017-09-10 17:25:29 +05:30
%tr
2021-01-03 14:25:43 +05:30
%td
- if registration[:name].present?
= registration[:name]
- else
%span.gl-text-gray-500
= _("no name set")
2020-11-24 15:15:51 +05:30
%td= registration[:created_at].to_date.to_s(:medium)
2021-01-03 14:25:43 +05:30
%td= link_to _('Delete'), registration[:delete_path], method: :delete, class: "gl-button btn btn-danger float-right", data: { confirm: _('Are you sure you want to delete this device? This action cannot be undone.') }
2016-09-13 17:45:13 +05:30
2017-09-10 17:25:29 +05:30
- else
.settings-message.text-center
2020-11-24 15:15:51 +05:30
- if webauthn_enabled
= _("You don't have any WebAuthn devices registered yet.")
- else
= _("You don't have any U2F devices registered yet.")