fix: update memory auth data.

oneRain 2021-02-01 16:57:45 +08:00
parent 8645caf4a3
commit 31c16cc7e2
2 changed files with 11 additions and 5 deletions

View File

@ -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();

View File

@ -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<string, object> authData) {
LCObjectData objData = new LCObjectData();
objData.CustomPropertyDict["authData"] = authData;
Merge(objData);
}
static async Task<LCUser> Login(Dictionary<string, object> data) {
Dictionary<string, object> response = await LCApplication.HttpClient.Post<Dictionary<string, object>>("login", data: data);
LCObjectData objectData = LCObjectData.Decode(response);