I have a problem with showing the correct login errors. This switch statement would occur when the app fails to register a player via an email (email, username and password). When I tested it, I used a username and email address that I know had been taken, but only the "EmailAddressNotAvailable" error seems to run and it says "username available" even though I know its not. When I change the email to a new email address it then says "username not available".
I wanted both errors to occur at the same time but it only seems to detect the email address error. Seems not to go through all the cases and not in order either as I place the UsernameError first in the switch.
I am something is wrong with my switch case statements. Here is my code.
privatevoidOnRegisterFailure(PlayFabError error)
{
Debug.LogError(error.GenerateErrorReport());
switch(error.Error)
{
casePlayFabErrorCode.UsernameNotAvailable:
RegisterUsernameErrorText.text =("Username Taken");
Debug.LogWarning("Register Fail Username Taken");
break;
casePlayFabErrorCode.EmailAddressNotAvailable:
RegisterEmailErrorText.text =("Email Already Registered");
Debug.LogWarning("Register Fail Email Already Registered");
break;
casePlayFabErrorCode.InvalidEmailAddress:
RegisterEmailErrorText.text =("Invalid Email");
Debug.LogWarning("Register Fail Invalid Email");
break;
default:
RegisterUsernameErrorText.text =("Username Available");
RegisterEmailErrorText.text =("Email Available");
Debug.LogWarning("Register default");
break;
}
}
I have tried the following code but have the same issue of it only detecting the email error first. I am unsure, but it may be that the playfab checks if the email is available and if it is not it produces that error and does not bother to check if the username is available. Once the email has been corrected, then maybe playfab checks if the username is available and finds it is not and generates an error.
private void OnRegisterFailure(PlayFabError error) { Debug.LogError(error.GenerateErrorReport());
if ((error.Error & PlayFabErrorCode.UsernameNotAvailable) == PlayFabErrorCode.UsernameNotAvailable)
{
RegisterUsernameErrorText.text = ("Username Taken");
Debug.LogWarning("Register Fail Username Taken");
}
else
{
RegisterUsernameErrorText.text = ("Username Available");
}
if ((error.Error & PlayFabErrorCode.EmailAddressNotAvailable) == PlayFabErrorCode.EmailAddressNotAvailable)
{
RegisterEmailErrorText.text = ("Email Already Registered");
Debug.LogWarning("Register Fail Email Already Registered");
}
else
{
RegisterEmailErrorText.text = ("Email Available");
}
}