Strip trailing spaces from login email

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.

5 Likes

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.

3 Likes

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

1 Like

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.

2 Likes

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

3 Likes

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

(Sign up form strips whitespace, checked earlier)

4 Likes

Fixed via:

https://github.com/discourse/discourse/commit/335e79777659f543d02d7f027b033b966d3bc866

OOPS: trip trim :blush:

6 Likes