openstax / accounts

OpenStax centralized authentication and accounts service

Home Page:https://accounts.openstax.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sign up is broken if username without spaces is taken

karenc opened this issue · comments

I tried to sign up on stage1 using my google login karen@karen-chan.com, it resulted in a blank page (See #123)

The traceback says it's "IllegalState" app/controllers/sessions_controller.rb:32 :in `block in callback'

It turns out that when I use my google login, it detected that my username should be "Karen Chan". It checks that there's no user with username "Karen Chan", then it tries to create a user with username "Karen Chan" which gets "santized" by the user model to "KarenChan", but there's already a user with username "KarenChan". So it failed and returned without any status.

Your google username has a space? Google!

This explains so many things...

So just need to sanitize the username before we check the existence of the user in the CreateUser routine.

Actually this happens because the OmniauthData class picks your full name as the username if it can't get a username from google.

So the best thing to do is probably to sanitize the name right there.