Sign In Register

How can we help you today?

Start a new topic
Answered

Checking if username is already in use

I create a game, where I need the username to be unique for all users. It's somewhat similar to this question , except that I don’t want to register the user. I basically only want to ask the backend, if the username is taken, and then get a bool in response. The reason for this is, that choosing username is only a step in the registration flow, which later concludes in the actual registration. I’m working in Unity. So any help on both the call from Unity and the CloudCode setup would be most valued! Thanks in advance!

Best Answer
So, you can preform a registration request as usual.
One of the error-code that comes back will tell you if the username is taken, you can use that error code to let the player know they need to choose another name.
You can check out the API for RegistrationRequest here.

Sean

 


Sorry for reopen this thread, but there is still one detail i`m in doubt.


Every request must be done with authenticated users, right?

So how can an unregistered user check if an username is already in use?

Consider I will use RegistrationRequest and my game username will be an email.

There's no way to check that before send the RegistrationRequest, right?


Thanks in advance.

Answer
So, you can preform a registration request as usual.
One of the error-code that comes back will tell you if the username is taken, you can use that error code to let the player know they need to choose another name.
You can check out the API for RegistrationRequest here.

Sean

 

Hi Morten,


One way you can track usernames of players is to mirror the Player collection on Registration, so that you can perform queries in Cloud Code on fields such as "userName".


Spark.runtimeCollection("playerList").find({"userName": input})


-Pádraig


Login to post a comment