2019-05-17 01:59:31 -04:00
- page_title _('Two-Factor Authentication'), _('Account')
- add_to_breadcrumbs(_('Two-Factor Authentication'), profile_account_path)
2017-06-22 10:47:50 -04:00
- @content_class = "limit-container-width" unless fluid_layout
2017-07-06 12:24:03 -04:00
2017-08-01 04:50:59 -04:00
.js-two-factor-auth{ 'data-two-factor-skippable' => "#{two_factor_skippable?}", 'data-two_factor_skip_url' => skip_profile_two_factor_auth_path }
.row.prepend-top-default
.col-lg-4
%h4.prepend-top-0
2019-05-17 01:59:31 -04:00
= _('Register Two-Factor Authenticator')
2016-06-06 00:44:51 -04:00
%p
2019-05-17 01:59:31 -04:00
= _('Use an one time password authenticator on your mobile device or computer to enable two-factor authentication (2FA).')
2017-08-01 04:50:59 -04:00
.col-lg-8
- if current_user.two_factor_otp_enabled?
2018-01-02 08:07:13 -05:00
%p
2019-05-17 01:59:31 -04:00
= _("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-07-19 06:38:04 -04:00
%p
2019-05-17 01:59:31 -04:00
= _('If you lose your recovery codes you can generate new ones, invalidating all previous codes.')
2018-07-19 06:38:04 -04:00
%div
2019-05-17 01:59:31 -04:00
= link_to _('Disable two-factor authentication'), profile_two_factor_auth_path,
2018-01-02 08:07:13 -05:00
method: :delete,
2019-05-17 01:59:31 -04:00
data: { confirm: _('Are you sure? This will invalidate your registered applications and U2F devices.') },
2018-07-19 06:38:04 -04:00
class: 'btn btn-danger append-right-10'
= form_tag codes_profile_two_factor_auth_path, {style: 'display: inline-block', method: :post} do |f|
2019-05-17 01:59:31 -04:00
= submit_tag _('Regenerate recovery codes'), class: 'btn'
2018-07-19 06:38:04 -04:00
2017-08-01 04:50:59 -04:00
- else
%p
2019-05-29 23:53:05 -04:00
- help_link_start = '<a href="%{url}" target="_blank">' % { url: help_page_path('user/profile/account/two_factor_authentication') }
- register_2fa_token = _('Install a soft token authenticator like %{free_otp_link} or Google Authenticator from your application repository and 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>' }
= register_2fa_token.html_safe
2017-08-01 04:50:59 -04:00
.row.append-bottom-10
.col-md-4
= raw @qr_code
.col-md-8
.account-well
%p.prepend-top-0.append-bottom-0
2019-05-17 01:59:31 -04:00
= _("Can't scan the code?")
2017-08-01 04:50:59 -04:00
%p.prepend-top-0.append-bottom-0
2019-05-17 01:59:31 -04:00
= _('To add the entry manually, provide the following details to the application on your phone.')
2017-08-01 04:50:59 -04:00
%p.prepend-top-0.append-bottom-0
2019-05-17 01:59:31 -04:00
= _('Account: %{account}') % { account: @account_string }
2017-08-01 04:50:59 -04:00
%p.prepend-top-0.append-bottom-0
2019-05-17 01:59:31 -04:00
= _('Key: %{key}') %{ key: current_user.otp_secret.scan(/.{4}/).join(' ') }
2017-08-01 04:50:59 -04:00
%p.two-factor-new-manual-content
2019-05-17 01:59:31 -04:00
= _('Time based: Yes')
2017-08-01 04:50:59 -04:00
= form_tag profile_two_factor_auth_path, method: :post do |f|
- if @error
.alert.alert-danger
= @error
.form-group
2019-05-17 01:59:31 -04:00
= label_tag :pin_code, _('Pin code'), class: "label-bold"
2017-08-01 04:50:59 -04:00
= text_field_tag :pin_code, nil, class: "form-control", required: true
.prepend-top-default
2019-05-17 01:59:31 -04:00
= submit_tag _('Register with two-factor app'), class: 'btn btn-success'
2016-06-06 00:44:51 -04:00
2017-08-01 04:50:59 -04:00
%hr
2016-06-06 00:44:51 -04:00
2017-08-01 04:50:59 -04:00
.row.prepend-top-default
.col-lg-4
%h4.prepend-top-0
2019-05-17 01:59:31 -04:00
= _('Register Universal Two-Factor (U2F) Device')
2017-08-01 04:50:59 -04:00
%p
2019-05-17 01:59:31 -04:00
= _('Use a hardware device to add the second factor of authentication.')
2017-08-01 04:50:59 -04:00
%p
2019-05-17 01:59:31 -04:00
= _("As U2F devices are only supported by a few browsers, we require that you set up a two-factor authentication app before a U2F device. That way you'll always be able to log in - even when you're using an unsupported browser.")
2017-08-01 04:50:59 -04:00
.col-lg-8
- if @u2f_registration.errors.present?
= form_errors(@u2f_registration)
= render "u2f/register"
2016-06-06 00:44:51 -04:00
2017-08-01 04:50:59 -04:00
%hr
2016-08-16 12:18:36 -04:00
2019-05-17 01:59:31 -04:00
%h5
= _('U2F Devices (%{length})') % { length: @u2f_registrations.length }
2016-08-16 12:18:36 -04:00
2017-08-01 04:50:59 -04:00
- if @u2f_registrations.present?
.table-responsive
%table.table.table-bordered.u2f-registrations
%colgroup
%col{ width: "50%" }
%col{ width: "30%" }
%col{ width: "20%" }
%thead
2016-08-16 12:18:36 -04:00
%tr
2019-05-17 01:59:31 -04:00
%th= _('Name')
2019-05-28 03:55:20 -04:00
%th= s_('2FADevice|Registered On')
2017-08-01 04:50:59 -04:00
%th
%tbody
- @u2f_registrations.each do |registration|
%tr
2019-05-17 01:59:31 -04:00
%td= registration.name.presence || _("<no name set>")
2017-08-01 04:50:59 -04:00
%td= registration.created_at.to_date.to_s(:medium)
2019-05-17 01:59:31 -04:00
%td= link_to _('Delete'), profile_u2f_registration_path(registration), method: :delete, class: "btn btn-danger float-right", data: { confirm: _('Are you sure you want to delete this device? This action cannot be undone.') }
2016-08-16 12:18:36 -04:00
2017-08-01 04:50:59 -04:00
- else
.settings-message.text-center
2019-05-17 01:59:31 -04:00
= _("You don't have any U2F devices registered yet.")