Implementing Login
1. Write the login script
Add content to the CustomLogin method in BackendLogin.cs written in Pre-arrangements.
BackendLogin.cs
Before modification
public void CustomLogin(string id, string pw)
{
// Logic for Step 3. Implementing Login
}
After modification
public void CustomLogin(string id, string pw)
{
Debug.Log("Requesting login.");
var bro = Backend.BMember.CustomLogin(id, pw);
if (bro.IsSuccess())
{
Debug.Log("Login successful. : " + bro);
}
else
{
Debug.LogError("Login failed. : " + bro);
}
}
2. Add method call to BackendManager.cs
BackendManager, which is automatically called when the game is executed, must be used to call this method.
Add it so that the method may be called after BACKND initialization.
BackendManager.cs
Before modification (after Step 2. Implementing Sign-up)
void Test()
{
BackendLogin.Instance.CustomSignUp("user1", "1234"); // [Addition] Sign up to BACKND
Debug.Log("Test complete.");
}
After modification
void Test()
{
BackendLogin.Instance.CustomLogin("user1", "1234"); // [Addition] Log in to BACKND
Debug.Log("Test complete.");
}
3. Test in Unity
After editing the script, execute Unity debugging and check the console log of Unity.
The method has been successfully called when the log displays 'Login successful. : statusCode: 200'.
When errors, such as statusCode : 400, 404, and 409, occur instead of the above log, you can check which error caused the failure in CustomLogin error case.
4. Check in the console
In BACKND Base > User Management
of BACKND Console, the registration date is the date the user signed up, and the last login date updates the user's most recent login date.
Therefore, the two dates are the same at the point of sign-up, but the last login date keeps changing because the sign-up and login dates become different.