Permalink
Please sign in to comment.
Showing
with
275 additions
and 2 deletions.
- +2 −0 Gemfile
- +6 −0 Gemfile.lock
- +35 −2 app/controllers/login_controller.rb
- +84 −0 app/controllers/settings_controller.rb
- +15 −0 app/models/user.rb
- +23 −0 app/views/login/twofa.html.erb
- +19 −0 app/views/settings/index.html.erb
- +32 −0 app/views/settings/twofa.html.erb
- +25 −0 app/views/settings/twofa_enroll.html.erb
- +24 −0 app/views/settings/twofa_verify.html.erb
- +10 −0 config/routes.rb
| @@ -0,0 +1,23 @@ | ||
| <div class="box wide"> | ||
| <div class="legend"> | ||
| Login - Two Factor Authentication | ||
| </div> | ||
| <%= form_tag twofa_login_url do %> | ||
| <p> | ||
| Enter the current TOTP code from your TOTP application: | ||
| </p> | ||
| <p> | ||
| <%= label_tag :totp_code, "TOTP Code:" %> | ||
| <%= text_field_tag :totp_code, "", :size => 10, :type => "number", | ||
| :autofocus => "autofocus" %> | ||
| <br /> | ||
| </p> | ||
| <p> | ||
| <%= submit_tag "Login" %> | ||
| </p> | ||
| <% end %> | ||
| </div> | ||
| @@ -0,0 +1,32 @@ | ||
| <div class="box wide"> | ||
| <div class="legend right"> | ||
| <a href="/settings">Back to Settings</a> | ||
| </div> | ||
| <div class="legend"> | ||
| <%= @title %> | ||
| </div> | ||
| <%= form_for @user, :url => twofa_auth_url, :method => :post do |f| %> | ||
| <p> | ||
| <% if @user.has_2fa? %> | ||
| To turn off two-factor authentication for your account, enter your | ||
| current password: | ||
| <% else %> | ||
| To begin the two-factor authentication enrollment for your account, | ||
| enter your current password: | ||
| <% end %> | ||
| </p> | ||
| <div class="boxline"> | ||
| <%= f.label :password, "Current Password:", :class => "required" %> | ||
| <%= f.password_field :password, :size => 40, :autocomplete => "off" %> | ||
| </div> | ||
| <p> | ||
| <% if @user.has_2fa? %> | ||
| <%= submit_tag "Disable Two-Factor Authentication" %> | ||
| <% else %> | ||
| <%= submit_tag "Continue" %> | ||
| <% end %> | ||
| <% end %> | ||
| </div> |
| @@ -0,0 +1,25 @@ | ||
| <div class="box wide"> | ||
| <div class="legend right"> | ||
| <a href="/settings">Back to Settings</a> | ||
| </div> | ||
| <div class="legend"> | ||
| <%= @title %> | ||
| </div> | ||
| <p> | ||
| Scan the QR code below or click on it to open in your <a | ||
| href="https://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm" | ||
| target="_blank">TOTP</a> application of choice: | ||
| </p> | ||
| <%= raw @qr_svg %> | ||
| <p> | ||
| Once you have finished registering with your TOTP application, proceed to | ||
| the next screen to verify your current TOTP code and actually enable | ||
| Two-Factor Authentication on your account. | ||
| </p> | ||
| <p> | ||
| <%= button_to "Verify and Enable", twofa_verify_url, :method => :get %> | ||
| </div> |
| @@ -0,0 +1,24 @@ | ||
| <div class="box wide"> | ||
| <div class="legend right"> | ||
| <a href="/settings">Back to Settings</a> | ||
| </div> | ||
| <div class="legend"> | ||
| <%= @title %> | ||
| </div> | ||
| <%= form_tag twofa_update_url do %> | ||
| <p> | ||
| To enable Two-Factor Authentication on your account using your new TOTP | ||
| secret, enter the six-digit code from your TOTP application: | ||
| </p> | ||
| <div class="boxline"> | ||
| <%= label_tag :totp_code, "TOTP Code:", :class => "required" %> | ||
| <%= text_field_tag :totp_code, "", :size => 10, :autocomplete => "off", | ||
| :type => "number", :autofocus => "autofocus" %> | ||
| </div> | ||
| <p> | ||
| <%= submit_tag "Verify and Enable" %> | ||
| <% end %> | ||
| </div> |
0 comments on commit
dbd84f1