show.html.haml 3.9 KB
Newer Older
T
Timothy Andrew 已提交
1 2
- page_title 'Two-Factor Authentication', 'Account'
- header_title "Two-Factor Authentication", profile_two_factor_auth_path
3
- @breadcrumb_title = "Two-Factor Authentication"
4
- @content_class = "limit-container-width" unless fluid_layout
5 6 7 8 9

- if show_new_nav?
  - content_for :header_title_before do
    = link_to "User Settings", profile_path

C
Connor Shea 已提交
10
= render 'profiles/head'
T
Timothy Andrew 已提交
11

12 13
- if inject_u2f_api?
  - content_for :page_specific_javascripts do
M
Mike Greiling 已提交
14
    = page_specific_javascript_bundle_tag('u2f')
15

T
Timothy Andrew 已提交
16
.row.prepend-top-default
17
  .col-lg-4
T
Timothy Andrew 已提交
18 19 20 21
    %h4.prepend-top-0
      Register Two-Factor Authentication App
    %p
      Use an app on your mobile device to enable two-factor authentication (2FA).
22
  .col-lg-8
T
Timothy Andrew 已提交
23 24 25 26 27
    - if current_user.two_factor_otp_enabled?
      = icon "check inverse", base: "circle", class: "text-success", text: "You've already enabled two-factor authentication using mobile authenticator applications. You can disable it from your account settings page."
    - else
      %p
        Download the Google Authenticator application from App Store or Google Play Store and scan this code.
28
        More information is available in the #{link_to('documentation', help_page_path('profile/two_factor_authentication'))}.
T
Timothy Andrew 已提交
29
      .row.append-bottom-10
30
        .col-md-4
T
Timothy Andrew 已提交
31
          = raw @qr_code
32
        .col-md-8
T
Timothy Andrew 已提交
33 34 35 36 37 38 39
          .account-well
            %p.prepend-top-0.append-bottom-0
              Can't scan the code?
            %p.prepend-top-0.append-bottom-0
              To add the entry manually, provide the following details to the application on your phone.
            %p.prepend-top-0.append-bottom-0
              Account:
40
              = @account_string
T
Timothy Andrew 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53
            %p.prepend-top-0.append-bottom-0
              Key:
              = current_user.otp_secret.scan(/.{4}/).join(' ')
            %p.two-factor-new-manual-content
              Time based: Yes
      = form_tag profile_two_factor_auth_path, method: :post do |f|
        - if @error
          .alert.alert-danger
            = @error
        .form-group
          = label_tag :pin_code, nil, class: "label-light"
          = text_field_tag :pin_code, nil, class: "form-control", required: true
        .prepend-top-default
54
          = submit_tag 'Register with two-factor app', class: 'btn btn-success'
T
Timothy Andrew 已提交
55 56 57 58 59

%hr

.row.prepend-top-default

60
  .col-lg-4
T
Timothy Andrew 已提交
61 62 63 64 65
    %h4.prepend-top-0
      Register Universal Two-Factor (U2F) Device
    %p
      Use a hardware device to add the second factor of authentication.
    %p
66 67 68
      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.
69
  .col-lg-8
T
Timothy Andrew 已提交
70 71 72 73
    - if @u2f_registration.errors.present?
      = form_errors(@u2f_registration)
    = render "u2f/register"

T
Timothy Andrew 已提交
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    %hr

    %h5 U2F Devices (#{@u2f_registrations.length})

    - if @u2f_registrations.present?
      .table-responsive
        %table.table.table-bordered.u2f-registrations
          %colgroup
            %col{ width: "50%" }
            %col{ width: "30%" }
            %col{ width: "20%" }
          %thead
            %tr
              %th Name
              %th Registered On
              %th
          %tbody
            - @u2f_registrations.each do |registration|
              %tr
                %td= registration.name.presence || "<no name set>"
                %td= registration.created_at.to_date.to_s(:medium)
                %td= link_to "Delete", profile_u2f_registration_path(registration), method: :delete, class: "btn btn-danger pull-right", data: { confirm: "Are you sure you want to delete this device? This action cannot be undone." }

    - else
      .settings-message.text-center
        You don't have any U2F devices registered yet.


T
Timothy Andrew 已提交
102 103 104 105
- if two_factor_skippable?
  :javascript
    var button = "<a class='btn btn-xs btn-warning pull-right' data-method='patch' href='#{skip_profile_two_factor_auth_path}'>Configure it later</a>";
    $(".flash-alert").append(button);