Merge pull request #83 from onerain88/verify_phone_number_modification

feat: 支持修改手机号验证功能
oneRain 2020-07-14 11:57:48 +08:00 committed by GitHub
commit fa33bfd651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -229,5 +229,17 @@ namespace Storage.Test {
//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");
}
}
}

View File

@ -555,5 +555,39 @@ namespace LeanCloud.Storage {
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);
}
}
}