> For the complete documentation index, see [llms.txt](https://docs.toomuchmedia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toomuchmedia.com/nats-admin/affiliates/further-reading/two-factor-authentication.md).

# Two-Factor Authentication

*Article Topics:* [*Affiliates*](/getting-started/common-topics/affiliates.md)

You can tie Google Authenticator to affiliate accounts and your admin through the [Affiliate Admin](/nats-admin/affiliates/further-reading/affiliate-activation.md). Multi-factor authentication (MFA) can also be called 2-factor authentication (2FA).&#x20;

## Enabling 2FA

1\) To access and enable the 2 Factor Authentication setting, navigate to the [Affiliate Admin](/nats-admin/affiliates.md) and select the affiliate you wish to manage.&#x20;

{% hint style="info" %}
**Please Note:** Admins can enable this for their accounts but affiliates will need the help of an admin to send them the QR code and enter their verification code.&#x20;
{% endhint %}

2\) Select the "**Update**" button beside the 2 Factor Authentication field.

<figure><img src="/files/aSJA02kGpEAzmOMIL2hN" alt=""><figcaption></figcaption></figure>

3\) Select the "**Ok**" button to generate a QR code that can be scanned in the Authenticator App of your choice. Some examples include the Google Authenticator App or the LastPass App.

<figure><img src="/files/kq4MC3X6vOGUzPe8Ey8u" alt=""><figcaption></figcaption></figure>

4\) Scan the QR Code in the Authenticator App.

<figure><img src="/files/bK0SHZNvpvrUGRgeNkGP" alt=""><figcaption></figcaption></figure>

5\) Type in the current token from your Authenticator app into the "**Token From App**" field.&#x20;

6\) Click the "**Enable 2 Factor**" option to enable 2FA for this affiliate account.&#x20;

{% hint style="warning" %}
**Important:** Should the Token you input be correct but you still receive an error, you may need to check your server time or change the value of the [G2FA Window ](#configuring-the-g2fa-window)in the [Configuration Admin](/nats-admin/configuration.md).
{% endhint %}

## Logging In

The affiliate should now have 2FA enabled for their account and will need to confirm their token when logging in.&#x20;

By default, the templates will only prompt for a 2FA token after a user has entered a valid username and password. You may wish to set up a [template ](/nats-admin/skins-and-templates/further-reading/templates.md)that always includes the field for the 2FA token, or does an Ajax call to verify username and password first before prompting for 2FA.&#x20;

<figure><img src="/files/bMpjrLc5WUGWc7DV5bHk" alt=""><figcaption></figcaption></figure>

You can modify the ***include\_affiliate\_login*** template, which is located in the Available Skins section of the [Skins & Templates](/nats-admin/skins-and-templates.md), by removing the "**{if $smarty.request.code == 12}**" and "**{/if}**" lines.&#x20;

### Before Template Change

{% code overflow="wrap" %}

```
{if $smarty.request.code == 12}
	<tr class="data-row-even-last">
		<td class="tab-column left-align" >
			<input type="text" autocomplete="off" name="twofactor" 		  	value="" placeholder="{#MFAToken#}" id="twofactor" class="edit-form-text-short" style="width: 200px;">
		</td>
		<td class="tab-column left-align" colspan="2"><a href="external.php?page=password" class="setLink" style="float: left;">{#ForgotPassword#}?</a></td>
	</tr>
{/if}		
```

{% endcode %}

### After Template Change

{% code overflow="wrap" %}

```
<tr class="data-row-even-last">
	<td class="tab-column left-align" >
		<input type="text" autocomplete="off" name="twofactor" 		  	value="" placeholder="{#MFAToken#}" id="twofactor" class="edit-form-text-short" style="width: 200px;">
	</td>
	<td class="tab-column left-align" colspan="2"><a href="external.php?page=password" class="setLink" style="float: left;">{#ForgotPassword#}?</a></td>
</tr>
```

{% endcode %}

## Configuring the G2FA Window

You can set how many seconds of difference is allowed between the current time on the server and the application by navigating to the [Configuration Admin's Security Tab ](/nats-admin/configuration/configuration-overview/security.md)and scrolling down to the Two-Factor Authentication section.&#x20;

<figure><img src="/files/xDsrVPyFwlQiYfxYQCWB" alt=""><figcaption></figcaption></figure>

## Related Articles

{% content-ref url="/pages/eLE5KhKhYac4R1XMX5sp" %}
[Affiliates](/nats-admin/affiliates.md)
{% endcontent-ref %}

{% content-ref url="/pages/PxTwVDhqrgJWAPfUQMvj" %}
[Security](/nats-admin/configuration/configuration-overview/security.md)
{% endcontent-ref %}
