Is there any way within FusionAuth to enforce the uniqueness of a username within an application?
-
Is there any way within FusionAuth to enforce the uniqueness of a username within an application?
-
The username on the user (
user.username) is unique and can be used to login. The username on the registrationregistration.usernameis not unique and cannot be used to login, it is intended to be used for display in an application. -
Hey @joshua,
Thanks for this Q&A, I have a question, what does this
uniqueUsernamemean and how it differs fromusername? E.g. code written in TS:await fusionAuthClient.updateUser(id, { user: { uniqueUsername: username, }, }); // vs await fusionAuthClient.updateUser(id, { user: { username: username, }, });How I register a user:
await fusionAuthClient.register('', { sendSetPasswordEmail: true, skipVerification: false, registration: { applicationId, }, user: { email, lastName, firstName, memberships, fullName: `${firstName} ${lastName}`, username, }, });Side note
I need username to be unique and I am utilizing
@fusionauth/react-sdk'suseFusionAuthhook. So basically IDK whetheruser.preferred_usernameis gonna be filled when I useuniqueUsernameboth inregistrationandupdateUseror not.And if the answer is negative* then should I manually write code to enforce uniqueness of username in my NestJS app?
*meaning if I use
uniqueUsernamein my frontend apppreferred_usernamewould be undefined