Alamin mohammed avatar image
Alamin mohammed asked

How do you displays login errors correctly?,How do you display email login errors?

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.

  1. privatevoidOnRegisterFailure(PlayFabError error)
  2. {
  3. Debug.LogError(error.GenerateErrorReport());
  4. switch(error.Error)
  5. {
  6. casePlayFabErrorCode.UsernameNotAvailable:
  7. RegisterUsernameErrorText.text =("Username Taken");
  8. Debug.LogWarning("Register Fail Username Taken");
  9. break;
  10. casePlayFabErrorCode.EmailAddressNotAvailable:
  11. RegisterEmailErrorText.text =("Email Already Registered");
  12. Debug.LogWarning("Register Fail Email Already Registered");
  13. break;
  14. casePlayFabErrorCode.InvalidEmailAddress:
  15. RegisterEmailErrorText.text =("Invalid Email");
  16. Debug.LogWarning("Register Fail Invalid Email");
  17. break;
  18. default:
  19. RegisterUsernameErrorText.text =("Username Available");
  20. RegisterEmailErrorText.text =("Email Available");
  21. Debug.LogWarning("Register default");
  22. break;
  23. }
  24. }

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");
         RegisterUsernameErrorText.text = ("Username Available");

     if ((error.Error & PlayFabErrorCode.EmailAddressNotAvailable) == PlayFabErrorCode.EmailAddressNotAvailable)
         RegisterEmailErrorText.text = ("Email Already Registered");
         Debug.LogWarning("Register Fail Email Already Registered");
         RegisterEmailErrorText.text = ("Email Available");
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Seth Du avatar image
Seth Du answered

It should be by design that email address will have higher priority to be checked in the backend. For "if…else" and "switch" conditions, the common design is to directly return when the first condition is passed. It is unnecessary for the server to continue to run the following codes when the error occurs.

Currently, there is no workaround for it. I will suggest sending a thread in the Feature Request forum and votes from developers can help with the priority.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alamin mohammed avatar image Alamin mohammed commented ·

Thanks for your answer. It's a shame the feature is not in there already.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.