question

DK avatar image
DK asked

Problem with unintended account duplication when using LoginWithEmail API

Hello,

I followed the steps below to create an account:

  1. Tried to log in with LoginWithEmail API.

  2. If there was no appropriate account in step 1, I created an account with the LoginWithCustomID API.

  3. Added email, password, and username using the AddUsernamePassword API.

  4. Went back to step 1 to try to log in again.

I confirmed that I was able to create one ID and input information successfully by following the above steps.

However, the problem occurs when I try to access the ID created above on a different device. (Let's call the original device "A" and the other device "B".)

First of all, it is possible to access the ID created through the above process on device "B" without any problems.

However, when I try to log in with step 1 on device "B," an additional account with a Custom ID Account is created.

The reason I call it step 1 is because the logs that should be shown in steps 2 and 3 are not visible.

If I check the account that was additionally created, there is no other information besides the Custom ID Account.

I would appreciate it if you could let me know why this situation is happening and what the solution is.

  • am not sure if this inquiry was written properly through translation. Please let me know if there is any additional information needed.

/* Here is the related code

     bool createaccount = false;
    
     public void Start()
     {
 #if UNITY_ANDROID && !UNITY_EDITOR
         LoginSet();
         GoogleLogin();
 #endif
     }
    
     void LoginSet()
     {
         PlayGamesPlatform.DebugLogEnabled = true;
         PlayGamesPlatform.Activate();
     }
    
     public void GoogleLogin()
     {
         createaccount = false;
         Social.localUser.Authenticate((success) =>
         {
             if (success) { PlayFabLogin(); }
         });
     }
    
     public void PlayFabLogin()
     {
         var request = new LoginWithEmailAddressRequest { Email = Social.localUser.id + "@test.com", Password = "test" + Social.localUser.id};
         PlayFabClientAPI.LoginWithEmailAddress(request, (result) => { OnLoginSuccess(result); }, 
             (error) => { createaccount = true; CustomIdLogin(); });
     }
    
     void CustomIdLogin()
     {
         PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest()
         {
             CustomId = SystemInfo.deviceUniqueIdentifier,
             CreateAccount = createaccount
         }, result =>
         {
             AddUsernamePassword(result);
         },
         (error) =>
         {
             OnLoginFailure(error);
         });
     }
    
     public void AddUsernamePassword(LoginResult result)
     {
         string email = Social.localUser.id + "@test.com";
         string password = "test" + Social.localUser.id;
         string username = result.PlayFabId;
         var request = new AddUsernamePasswordRequest
         {
             Email = email,
             Password = password,
             Username = username,
         };
         PlayFabClientAPI.AddUsernamePassword(request, res => {
             PlayFabLogin();
         }, error => {
         });;
     }
apisAccount Management
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

·
Xiao Zha avatar image
Xiao Zha answered

Based on your description, it seems that you have followed the steps above to create an CustomId account with email address and password, then you used the same email address and password to call the LoginWithEmailAddress API on another device, which created a new custom Id account instead of logged in with the email address. If this is the case, since I can't reproduce your problem, could you please share the code of the whole process with us so we can have look.

4 comments
10 |1200

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

DK avatar image DK commented ·

I have summarized the relevant code at the bottom of the post.

"Step 1" includes the "PlayFabLogin" function, "Step 2" includes the "CustomIdLogin" function, and "Step 3" includes the "AddUsernamePassword" function.

Additional note: Even if I only delete the account with the CustomId and successfully log in through "Step 1", I have confirmed that a new empty account with the CustomId is created.

If you need anything else, feel free to let me know and I will comment back as soon as possible.

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha DK commented ·

PlayFab won’t create the customId account automatically for you. And only when you call the LoginWithCustomId API, the customId account will be created.

You may check if the CustomId of the newly created custom empty account is the same as the “SystemInfo.deviceUniqueIdentifier” of the device B, if yes, the LoginWithCustomID API must be called somewhere in your code, you may try to add some breakpoint to debug to find out the issue.

Also, please confirm that the email address and password is same and correct when you logged in with different device.

1 Like 1 ·
DK avatar image DK Xiao Zha commented ·

Oh, I apologize. It was clearly my mistake. After debugging, I was able to confirm that another script was referring to an API using the Custom ID.

Thank you Xiao Zha!

1 Like 1 ·
Show more comments

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.