Two Factor Authentication

<%= form_for @changeset, ~p"/registrations/totp", [as: :user], fn f -> %> <%= if @changeset.action do %>

Oops, something went wrong! Please check the errors below.

<% end %> <%= if @current_user.otp_required_for_login do %> <%= if !@changeset.action and get_flash(@conn, :totp_backup_codes) do %>

Important - Save The Below Codes

The backup codes shown in the green box below are necessary to regain access to your account in the event of you losing access to your authenticator app (such as loss, theft, or damage to your phone). It is extremely important that you write them down and store them in a safe, secure place. If you lose access to you authenticator app and do not have one or more of the above codes, we will be unable to help you regain access to your account.


Two Factor Authentication Enabled

You've successfully enabled two factor authentication on your account. From now on you'll be asked for the 6 digit code each time you log in.

In case you lose your device or uninstall the application, you will need one of the following backup codes to access to your account:


Make sure to write these down (preferably on paper) and store them in a safe location, otherwise you may permanently lose access to your account.

<% end %>

Two factor authentication is currently enabled for your account.

Enter the generated 6-digit code or one of your backup codes to disable.

Note that the 6-digit codes are limited to a single use within their lifespan of 30 seconds, so if you just logged in with a code, entering it again here will cause an error. If that's the case, just wait for a new code to be generated.

<%= text_input(f, :twofactor_token, class: "input", placeholder: "6-digit code") %> <%= error_tag(f, :twofactor_token) %>
<% else %>

Two factor authentication is currently disabled for your account.


Enabling 2FA will make it harder for an attacker to get into your account, but it may also make it harder for you to get into your account. Make sure you'll have access to your authenticator if you enable it.

Download application

You will need an application on your phone that'll generate TOTP codes for you, such as:

Pair application

Using the application of your choice, scan the QR code below or enter the following secret key: <%= @totp_secret %>

Confirm pairing

Enter the code generated by your authenticator app into the field below for verification.

<%= text_input(f, :twofactor_token, class: "input", placeholder: "6-digit code", autocomplete: "off") %>

Note that the 6-digit codes are limited to a single use within their lifespan of 30 seconds, so if you use a code to enable the feature here, you won't be able to immediately use the same code to log in or to disable the feature. You have to wait for a new code to be generated.

Warning - Authenticator Backup Codes

Once you enable 2FA on your account, you will be provided with a list of backup codes that can be used to access your account in the event of you losing access to your authenticator app. You will only be provided with these codes once, so please ensure that you have a way to safely and securely record them before enabling 2FA on your account. If you lose access to your authenticator app and do not have your backup codes, you will be locked out of your account permanently, and we will be unable to assist you.

<% end %>
<%= password_input(f, :current_password, class: "input", placeholder: "Current password") %> <%= error_tag(f, :current_password) %>
We need your current password to confirm these changes

<%= submit("Save Account", class: "button") %>
<% end %>

<%= link("Back", to: ~p"/registrations/edit") %>