# Strip trailing spaces from login email

**URL:** https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508
**Category:** Bug
**Created:** [09.Декабрь.2015 23:51:35 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508 "2015-12-09T23:51:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![ky\_metro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ky_metro/32/42807_2.png) [@ky\_metro](https://meta.discourse.org/u/ky_metro)
#### Post date: [09.Декабрь.2015 23:51:35 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/1 "2015-12-09T23:51:35Z")

</div>

Mobile keyboards tend to add spaces when auto-completing words. We don’t strip trailing spaces from email addresses on the login screen. I’ve had users trying to log in on mobile run into this, it returns `"no account matches xyz@mail.com"`, for an account that does exist.

They are stripped from the invite form already. We should strip them on login too.

> [@'Send Invite' button greyed-out and inoperative if there is a trailing space after the email address](https://meta.discourse.org/t/send-invite-button-greyed-out-and-inoperative-if-there-is-a-trailing-space-after-the-email-address/28869/2):
>
> @techAPJ it would be smart to strip leading/trailing spaces before validation (and of course submit those stripped versions to the server too.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [09.Декабрь.2015 23:52:41 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/2 "2015-12-09T23:52:41Z")

</div>

Agreed @techapj can you take this? Anywhere the user can input data on signup (or login) we should be stripping leading and trailing spaces either during or prior to submission.

---

<div class="post-metadata">

### Author: ![watchmanmonitor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/watchmanmonitor/32/430970_2.png) [@watchmanmonitor](https://meta.discourse.org/u/watchmanmonitor)
#### Post date: [10.Декабрь.2015 04:43:40 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/3 "2015-12-10T04:43:40Z")

</div>

I’m forever copying email addresses in some manner that has a leading space.. will be glad to see this managed!

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [10.Декабрь.2015 08:30:34 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/4 "2015-12-10T08:30:34Z")

</div>

We does strip the the leading/trailing spaces from username/email via:

> <https://github.com/discourse/discourse/blob/master/app/controllers/session_controller.rb#L141>

I am not able to repro the issue (on Desktop/Mobile) where leading/trailing spaces causes login error.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [10.Декабрь.2015 08:35:25 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/5 "2015-12-10T08:35:25Z")

</div>

Is this true for password reset form as well, though?

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [10.Декабрь.2015 08:39:15 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/6 "2015-12-10T08:39:15Z")

</div>

Good catch! Not true in case of password reset, fixing now.

(Sign up form strips whitespace, checked earlier)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [10.Декабрь.2015 09:08:21 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/7 "2015-12-10T09:08:21Z")

</div>

Fixed via:

[https://github.com/discourse/discourse/commit/335e79777659f543d02d7f027b033b966d3bc866](https://github.com/discourse/discourse/commit/335e79777659f543d02d7f027b033b966d3bc866)

OOPS: ~~trip~~ trim 😊

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [10.Декабрь.2015 09:11:20 UTC](https://meta.discourse.org/t/strip-trailing-spaces-from-login-email/36508/8 "2015-12-10T09:11:20Z")

</div>


