1. Home
  2. Docs
  3. UniREST Solution 3.5
  4. UniREST Client
  5. Login and Registration
  6. User Login

User Login

The user login operation opens a communication channel between your game and your Server. When the login occurs without problems, the UniREST Server application replies with a set of data which is required for the next communication and for the correct functioning of the whole system. The server-side reply consists of:

  • the ID of the user account;
  • the security Tokens needed for authorizing the operations on your Server.

The login is performed by the Login() method. It just requires the user account username and password:

_ = UniRESTClient.Async.Login(username, password, callBack);
ParameterData-typeDescription
usernamestringThe user username. The maximum allowed length is 32 characters.
passwordstringThe user password.
callBackAction<bool>The function to call or the code to execute at operations completed.
Returned valueDescription
boolThis method just returns true or false.

If the user login occurs without problems, this method returns true. The system data received from the Server (user’s ID and tokens) gets integrated into the UniREST system.

If something goes wrong and the login fails, this method returns false.

_ = UniRESTClient.Async.Login("pluto", "planet9", (bool ok) =>
    {
       if (ok)
       {
           Debug.Log("Login done!");
       }
       else
       {
           Debug.Log("Login failed!");
       }
    });

User ID

The user account ID, that the UniREST Client receives after a successful login, is stored into the UniRESTClient class and is always available in the UserID property:

UniRESTClient.UserID;

You can always refer to this property when you need to do something with the user ID (for example, you want to update a record that contains the user ID).

In case of failure, a special code is released to the UniRESTClient class. See the ''Technical Details'' chapter for more info.

User Account details

Once the user logged-in, the UniRESTClient class userAccount property is initialized with the user account-related data.

UniRESTClient.userAccount;
userAccount propertyData-typeDescription
.usernamestringThe current user’s username.
.passwordstringThe current user’s password.
.lastLoginDatestringThe date of the last performed login.
.registrationDatestringThe date when this account has been registered.
_ = UniRESTClient.Async.Login("pluto", "planet9", (bool ok) =>
    {
       if (ok)
       {
           Debug.Log("Login done!");
           Debug.Log("pluto is here from: " + UniRESTClient.userAccount.registrationDate);
           Debug.Log("Last access: " + UniRESTClient.userAccount.lastLoginDate);
       }
       else
       {
           Debug.Log("Login failed!");
       }
    });