Checking For Unique Username via API?

We are using Discourse with SSO and are creating users via the API.

There is concern that if we leverage the email address for the username it will be easy to guess personal emails at gmail so we’d like to just create unique usernames by using First Name + a Number (eg Bill1, Bill2, Bill3) and users can always change them.

Is there a way to check if a username is unique via the API? The thought is that we can keep looping until we find a username that is unique.

Also would be interested to hear if anyone has any other ideas for an alternate approach. One thought was doing something like First Name + Last Initial + 4 Random numbers or similar.

Thanks

We are using Discourse with SSO and are creating users via the API.

Clarification: Are you using Discourse Connect or creating the users by hand?

It kind of sounds like you’re doing more work than you need to.

Using Discourse Connect is probably easier and then you can let Discourse itself find a unique username that’s close to what you suggest.

2 Likes

Thanks for your response @supermathie . We are using Discourse connect and as it turns out whenI send Bill two times the second Bill is created as Bill1 so it looks like I’m good. Appreciate your help!

1 Like

Exactly! The most important thing is keeping your external ID unique for the user. pass in a “sensible” username and let Discourse do the work.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.