julianlam / nodebb-plugin-sso-google

NodeBB Plugin that allows users to login/register via their Google account.
BSD 2-Clause "Simplified" License
20 stars 16 forks source link

Generate a random id for the username using shortid. #4

Closed joe1chen closed 9 years ago

joe1chen commented 10 years ago

Using the handle as username is problematic since handle can be something like "John Smith". Instead set the fullname of the user to the handle and generate a random username.

julianlam commented 10 years ago

Hi @joe1chen -- is there a need for a shortid to be generated? NodeBB's usernames can handle spaces, so I see no reason to force the user to pick a new username.

joe1chen commented 10 years ago

Hi @julianlam, my understanding was that username needs to be unique in NodeBB. So if 2 different users with the handle "John Smith" login with the social login (Google, Facebook, etc.) then the second one will result in a username collision and then the login fails.

I think I ran into this issue just by testing my various social logins. With these social logins, I didn't see any error recovery mechanism for when an error occurs. Ideally they would be redirected to the registration page with their email pre-filled, and then asked to select a new username.

julianlam commented 10 years ago

If two users register with the same display name, NodeBB will automatically append a string of numbers to the end of the duplicate user upon creation.

Is that no longer happening?

joe1chen commented 10 years ago

For some reason I did not see this behavior. Or maybe there was something else causing a login error.

Is it possible that the strings were being appended but the resulting username exceeded the max length for usernames?

In any case, I will try to retest and see if I can determine the exact error.