PlayerIO

The fastest way to build online games without breaking a sweat.

Simple Users Authentication

If all you want is an easy way for your users to be able to register and login to your game, with usernames and passwords that are unique to your game, Simple Users Authentication is the solution for you.

You can view a list of all users that have registered using this method in your game, and you can export this list at any time. This means that even if you start using this as a user database, you can move those users to your own database at any time - you own your users completely.

Control Panel Setup

When you create a connection that uses the Simple Users authentication type, all you need to do is decide what rules should apply during registration. If you want to require all users to submit a valid and unique email-address, check that option. If you want to use the Captcha during registration, choose which Captcha type you want.

Registering a user

To register a user your game should present a registration form that contains at least username and password input fields. When the user clicks register you should then call the Authenticate() method with the registration data. You can also collect additional information such as email, birthdate, gender or similar and pass that into the registration method. Note that this data cannot be changed after registration, and cannot be accessed through the client libraries. However, viewing or exporting your users will allow you to see everything you gathered.

To pass in custom data to be stored with your user, simply add those keys and values to the authentication arguments.

If there are any problems with the registration data, check the Message in the error callback to find out what was wrong, and optionally present that to the user.

Authenticating

When a registered user returns to your game you should ask for the users username or email, and password, and then call the Authenticate method with those arguments to authenticate him. If the password matches the user, you will get back an open connection.

You must pass in the 'password' argument, and you must pass in either 'username' or 'email', or both.

Checking if a username or email address is taken

Normally when registering a user, you will get an error message back if the username or (optionally) the email address has already been registered by another user.

To provide a better registration experience for the user, you can call the Authenticate method with a special argument to make it just check if a username or email address has been taken. This way, you can tell the user if a username or email address is unavailable before the user has finished filling out all registration data.

This method will always return an error, and you need to check which error you got to determine the outcome. If you got an UnknownUser error, then the username or email that you passed in have not been registered by another user and are free. Any other error either means that you either passed in the wrong arguments, or that the username or email is already taken. Check the error message to see exactly what happened.

Changing the password of a user

The best way for a user to change their password is for you to call the SimpleRecoverPassword method in QuickConnect, because that will automatically send an email to the user, allowing them to securely change their password in the game at their convenience. However, if the user never registered an email address in the first place, or if they no longer have access to the email address they used when they first registered, that option doesn't work.

Therefore, you can call the Authenticate method with a special argument to change the password of a user. You need to provide either the username or email address of the user, and you also need both the old password and the new.

This method will always return an error, and you need to check which error you got to determine the outcome. If you got a GeneralError error and the error message contains the text "Password changed", then the password has been successfully changed for the user. Any other error either means that you either passed in the wrong arguments, or that the old password was wrong. Check the error message to see exactly what happened.

Changing the email address of a user

If the user never registered an email address, or if the user has changed their email address, but want to be able to user the account recovery feature, there is a way to change the registered email address of a user.

You do that by calling the Authenticate method with a special argument to change the emaill address of a user. You need to provide either the username or current email address of the user, you need to provide the password for security, and you need to provide the new email address.

This method will always return an error, and you need to check which error you got to determine the outcome. If you got a GeneralError error and the error message contains the text "Email address changed", then the email address has been successfully changed for the user. Any other error either means that you either passed in the wrong arguments, or that the new email address was already registered. Check the error message to see exactly what happened.