From 31c16cc7e2371aaab4958bb06f25fae2baf58da3 Mon Sep 17 00:00:00 2001 From: oneRain Date: Mon, 1 Feb 2021 16:57:45 +0800 Subject: [PATCH] fix: update memory auth data. --- Storage/Storage.Test/UserTest.cs | 4 ++-- Storage/Storage/LCUser.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Storage/Storage.Test/UserTest.cs b/Storage/Storage.Test/UserTest.cs index 7d1ba8b..99f320a 100644 --- a/Storage/Storage.Test/UserTest.cs +++ b/Storage/Storage.Test/UserTest.cs @@ -49,7 +49,7 @@ namespace Storage.Test { Assert.NotNull(current.ObjectId); Assert.IsFalse(current.EmailVerified); Assert.IsFalse(current.MobileVerified); - Assert.AreEqual(current.Mobile, "15101006008"); + Assert.AreEqual(current.Mobile, "15101006007"); } [Test] @@ -70,7 +70,7 @@ namespace Storage.Test { [Test] public async Task RelateObject() { - LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "112358"); + LCUser user = await LCUser.LoginByMobilePhoneNumber("15101006007", "world"); LCObject account = new LCObject("Account"); account["user"] = user; await account.Save(); diff --git a/Storage/Storage/LCUser.cs b/Storage/Storage/LCUser.cs index 4b20305..7a5b1dd 100644 --- a/Storage/Storage/LCUser.cs +++ b/Storage/Storage/LCUser.cs @@ -531,8 +531,8 @@ namespace LeanCloud.Storage { }; try { await Save(); - oriAuthData.Add(authType, data); - AuthData = oriAuthData; + oriAuthData[authType] = data; + UpdateAuthData(oriAuthData); } catch (Exception e) { AuthData = oriAuthData; throw e; @@ -547,13 +547,19 @@ namespace LeanCloud.Storage { try { await Save(); oriAuthData.Remove(authType); - AuthData = oriAuthData; + UpdateAuthData(oriAuthData); } catch (Exception e) { AuthData = oriAuthData; throw e; } } + private void UpdateAuthData(Dictionary authData) { + LCObjectData objData = new LCObjectData(); + objData.CustomPropertyDict["authData"] = authData; + Merge(objData); + } + static async Task Login(Dictionary data) { Dictionary response = await LCApplication.HttpClient.Post>("login", data: data); LCObjectData objectData = LCObjectData.Decode(response);