Feature: create default user name from email's user portion when using Google OAuth2/SSO

I hope it’s ok to post random feature requests/suggestions here.

I have a Discourse instance set up so that users can authenticate with a Google Apps Hosted Domain (in my case @vt.edu). I have observed that Discourse assigns user names based on combining first + last name it obtains via OAuth2 - e.g., First_Last.

What I’d much prefer is if the proposed username matched the user portion of the email account user@vt.edu since user is an identifier used elsewhere whereas First_Last is not. Moreover, First_Last is not guaranteed to be unique (John_Smith) whereas the user id is. This would for my use case help with the data explorer plugin when I need to match statistics against other records and just provide an overall more uniform experience.

1 Like

I believe @andrei removed this altogether as there were privacy implications when “automatically” creating a username based on email?

1 Like

Not exactly. We’re not removing this, we’re just disabling it with ability to turn it on using the use_email_for_username_and_name_suggestions site setting.

Also, note that this change is done for DiscourseConnect, but not for other authentication methods (including authentication via Google). But the fix for other methods is coming soon.

Also, when generating username, full name have priority over email, authenticators try to use email for username suggestions only if the username and full-name fields in the payload are empty. This is something that can be customized with a plugin. But using email as the main source for username suggestions isn’t something that we want to do by default, especially for authentication via Google. The reason is that in this case, it’s possible to figure out emails of all users on the forum just by adding @gmail.com to usernames.

1 Like