# Tidy 2FA code before verification

**URL:** https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103
**Category:** Feature
**Created:** [July 25, 2018, 2:25pm UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103 "2018-07-25T14:25:44Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Pixipea](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pixipea/32/568969_2.png) [@Pixipea](https://meta.discourse.org/u/Pixipea)
#### Post date: [July 25, 2018, 2:25pm UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/1 "2018-07-25T14:25:44Z")

</div>

With 2FA enabled, when the user types in their token with a space, we should automatically remove that before verifying the code.

As per:  
[https://twitter.com/simoncozens/status/1021743003344535552](https://twitter.com/simoncozens/status/1021743003344535552)

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [July 25, 2018, 3:09pm UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/3 "2018-07-25T15:09:09Z")

</div>

We have a limit for how many characters can be entered into the input field and with additional spaces the 2FA code doesn’t fit (which makes it obvious that only numbers should be entered). Should the `maxlength="6"` attribute of the input field really be loosened to allow any number of spaces the user might want to add?

---

<div class="post-metadata">

### Author: ![Pixipea](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pixipea/32/568969_2.png) [@Pixipea](https://meta.discourse.org/u/Pixipea)
#### Post date: [July 25, 2018, 3:30pm UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/4 "2018-07-25T15:30:53Z")

</div>

Perhaps this is just a problem when putting the 2FA code into the enable field, when first setting up 2FA.

Admittedly I am viewing this from more of a plebeian angle, but when I entered my 2FA code from Google Authenticator, which looks like this ### ###, I had no problems entering all 6 characters with the space in between.  
Shouldn’t the maxlength=“6” have prevented this?  
Maybe change the field input site to be numeric only?

does any of this make sense?

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [July 25, 2018, 3:37pm UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/5 "2018-07-25T15:37:04Z")

</div>

> [@Pixipea](#):
>
> Shouldn’t the maxlength=“6” have prevented this?

It should indeed, I only checked the input field which is part of login, looks like the other one which is part of enabling 2FA doesn’t have a limit in place. Will change that 🙂

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [August 27, 2018, 8:08am UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/6 "2018-08-27T08:08:05Z")

</div>

Fixed while ago in:  
[https://github.com/discourse/discourse/commit/e8d82f48bca79bcb531d769cda4ed6a24e321bbe](https://github.com/discourse/discourse/commit/e8d82f48bca79bcb531d769cda4ed6a24e321bbe)

---

<div class="post-metadata">

### Author: ![maja](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maja/32/129533_2.png) [@maja](https://meta.discourse.org/u/maja)
#### Post date: [August 27, 2018, 8:08am UTC](https://meta.discourse.org/t/tidy-2fa-code-before-verification/93103/7 "2018-08-27T08:08:09Z")

</div>


