How to check if a username is already taken (without using the email field)

For anyone who may need the knowledge (or perhaps you have a better solution to share), here’s a tip on how to validate a chosen username against the Users collection without putting a selected username into the email field. This is to prevent someone from using a username that already exists while still keeping the email field intact (useful for password resets).

Took me a hot minute to figure out the best way to make this process work, especially since I didn’t want to lose the email field as an email field, and also wasn’t a huge fan of someone signing up with a duplicate username, the auto warning says “this email already exists.” That would be super confusing if a user wasn’t signing up with an email.

So, here’s what I’ve done. Traditional sign up using email/password > next screen is profile setup where the user chooses a username.

Have a custom field for inputting the username. Under that, place a button to update the logged in user’s Username or invalidate if the username is taken.

Make that button a list tied to the Users collection > All Users. Set two filters on the list where “input” (your custom input field) is equal to Username OR “input” is not equal to Username. Be sure to set the max number of displayed list items to “1”

Now, head to the button component of that list and set the actions. First action is Update Logged in User (be sure to set the magic text in the username field as your custom input). On that action, set a variable to only perform the action if custom input is NOT equal to “current user’s username.” (This is what really got me hung up, which I can explain later if anyone needs to know)

Create another action to alert (I used a floater screen) if the username is taken. Set the variable of this action to only perform if the custom input IS equal to “current user’s username.”

And voila, you can now validate a new user’s username against what’s already available in the Users collection.

Tip: I would advise setting another action to link to the next screen (or something similar) IF the “update logged in user’s Username” is successful, otherwise by successfully updating the logged in user’s username field will bounce against your validations and display your pop up that the username is already taken (since technically it is according to what the workflow is looking for).

Hopefully this helps folks looking to achieve this goal, and could be applied to other validations other than usernames (and emails, since that’s done automatically).

Note: I can share a video if needed.

Edit: for the success page, it’s important to set the action to only direct to the success page IF your custom input field is equal to logged in user’s username; experimented with this a bit and this works the best. Your flow of button actions should go (from top to bottom): Update > Success > Fail


Thanks! I will use this method.

1 Like

Please I really need the video…thanks

1 Like

@Michael can you create a username component for the community with this concept?

I’ll put one together and try to get it posted this evening

1 Like

Hi @preptogether,

Nice method! Thanks for sharing!

Don’t think that I’m hijacking your tutorial :joy: but just adding that you don’t need a button with list and you can have only the button and make the Update action conditional with All Users > Count and filter it! Check this post, posted by Bobby for better understanding! : Unique Usernames AND Emails - #7 by Bobby

Also you can watch this video made by Victor for this not duplicate feature : Adalo Hints: how to prevent from creating duplicate records in the collection - YouTube

Hope this helps!

Thank you