Recreating the single sign on logic for generating usernames

Howdy,

I’m pre-populating users in Discourse from an integrated SSO external system and would like to mimic the username creation process in Discourse.

Currently, I’m having to create usernames like so, where the number is the unique user id.

u12345678
u23456789

I tried using portions of name or email but always ended up with complaints about special characters.

When a user logs into the site using SSO, the username is automagically created. The username is a reasonable representation of the user and I’d like to copy this functionality with my pre-populated users.

Does anyone know what the logic is and/or can point me to the code in GIT that performs the magic?

Thank you.

Here you go:

9 Likes

So if I understand this correctly, Discourse automagically does this when you have SSO setup/integrated?

1 Like

Only if you don’t supply a valid username.

2 Likes

Ok - so if we use SSO (Auth0) and when it goes to create a username, if there’s one already existing in Discourse with that name then it will create a different one, like a variation?

2 Likes