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.username
is 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
uniqueUsername
mean 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
'suseFusionAuth
hook. So basically IDK whetheruser.preferred_username
is gonna be filled when I useuniqueUsername
both inregistration
andupdateUser
or 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
uniqueUsername
in my frontend apppreferred_username
would be undefined