Bad automatic choosing of username when using SSO (DiscourseConnect)

I’m using SSO (DiscourseConnect) with my Discourse, and it works fine, except for one thing: my SSO is e-mail based, so users just choose e-mail, password and that’s it.

So my SSO returns just the e-mail, not an username. If an user with that e-mail doesn’t exist in Discourse, it will create one automatically, and try to fill in an user name automatically.

I thought Discourse would find a nice unique username based on the e-mail, but what it does is create a bunch of “user_a”, “user_a1”, etc.:

Is there a way to tell Discourse to pick a better username from the SSO?

With FEATURE: Optionally skip using real name when suggesting usernames by davidtaylorhq · Pull Request #16592 · discourse/discourse · GitHub the default was changed to use generic usernames as a lot of sites were finding users’ emails revealed by the generated usernames.

Take a look at use email for username and name suggestions and use name for username suggestions in your site settings to adjust this behaviour for your needs.