Skip to content

Commit

Permalink
Merge pull request #83 from onerain88/verify_phone_number_modification
Browse files Browse the repository at this point in the history
feat: 支持修改手机号验证功能
  • Loading branch information
onerain88 authored Jul 14, 2020
2 parents f88b095 + b1d1a3c commit fa33bfd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Storage/Storage.Test/UserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,17 @@ public async Task AssociateAuthDataWithUnionId() {
//public async Task ResetPasswordBySMSCode() {
// await LCUser.ResetPasswordBySmsCode("15101006007", "732552", "112358");
//}

[Test]
public async Task RequestSMSCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world");
await LCUser.RequestSMSCodeForUpdatingPhoneNumber("15101006007");
}

[Test]
public async Task VerifyCodeForUpdatingPhoneNumber() {
await LCUser.Login("hello", "world");
await LCUser.VerifyCodeForUpdatingPhoneNumber("15101006007", "055595");
}
}
}
34 changes: 34 additions & 0 deletions Storage/Storage/LCUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,39 @@ static void MergeAuthData(Dictionary<string, object> authData, string unionId, L
authData["main_account"] = option.AsMainAccount;
authData["unionid"] = unionId;
}

/// <summary>
/// 请求修改手机号验证码
/// </summary>
/// <param name="mobile"></param>
/// <param name="ttl"></param>
/// <param name="captchaToken"></param>
/// <returns></returns>
public static async Task RequestSMSCodeForUpdatingPhoneNumber(string mobile, int ttl = 360, string captchaToken = null) {
string path = "requestChangePhoneNumber";
Dictionary<string, object> data = new Dictionary<string, object> {
{ "mobilePhoneNumber", mobile },
{ "ttl", ttl }
};
if (!string.IsNullOrEmpty(captchaToken)) {
data["validate_token"] = captchaToken;
}
await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: data);
}

/// <summary>
/// 验证修改手机号验证码
/// </summary>
/// <param name="mobile"></param>
/// <param name="code"></param>
/// <returns></returns>
public static async Task VerifyCodeForUpdatingPhoneNumber(string mobile, string code) {
string path = "changePhoneNumber";
Dictionary<string, object> data = new Dictionary<string, object> {
{ "mobilePhoneNumber", mobile },
{ "code", code }
};
await LCApplication.HttpClient.Post<Dictionary<string, object>>(path, data: data);
}
}
}

0 comments on commit fa33bfd

Please sign in to comment.