> 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*](https://docs.toomuchmedia.com/getting-started/common-topics/affiliates.md)

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

## Enabling 2FA

1\) To access and enable the 2 Factor Authentication setting, navigate to the [Affiliate Admin](https://docs.toomuchmedia.com/nats-admin/affiliates.md) and select the affiliate you wish to manage.

{% 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.
{% endhint %}

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

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FmJZkJuP7CpXmNb2Jr2KR%2Fnatsadmin-affiliates-2FA.png?alt=media&amp;token=2c7e22c0-34e3-4e4d-9298-b6f5f17ff934" 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="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FMHf1oaGIWJ5Lwvz12wkx%2Fnatsadmin-affiliates-2FA-secret.png?alt=media&amp;token=f845d071-ac33-4caa-a946-4c4ebf3e92d1" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FwcNvPUDxnPpg3LnFw96a%2Fqrcode_test.png?alt=media&amp;token=2f9a40db-abab-4b77-b71d-c3f182140077" alt=""><figcaption></figcaption></figure>

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

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

{% 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](https://docs.toomuchmedia.com/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.

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 ](https://docs.toomuchmedia.com/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.

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FrI4lQ8h6OJdQ7m9Qgdwk%2Fnatsadmin-affiliates-2FA-denied.png?alt=media&amp;token=b98a9668-879d-4ff6-b8e8-da5edb3b3f3f" alt=""><figcaption></figcaption></figure>

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

### 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 ](https://docs.toomuchmedia.com/nats-admin/configuration/configuration-overview/security.md)and scrolling down to the Two-Factor Authentication section.

<figure><img src="https://2232071635-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWJVne6meHqGT8rzsBdod%2Fuploads%2FuLwHMKuDAXNBOIOljZpl%2Fnatsadmin-affiliates-2FA-configuration.png?alt=media&amp;token=abd176ec-1ea4-434f-b161-4f452626d763" alt=""><figcaption></figcaption></figure>

## Related Articles

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

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