feat: 支持修改手机号验证功能

oneRain 2020-07-14 11:51:30 +08:00
parent f88b0952ca
commit b1d1a3c77c
2 changed files with 46 additions and 0 deletions

View File

@ -229,5 +229,17 @@ namespace Storage.Test {
//public async Task ResetPasswordBySMSCode() { //public async Task ResetPasswordBySMSCode() {
// await LCUser.ResetPasswordBySmsCode("15101006007", "732552", "112358"); // 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["main_account"] = option.AsMainAccount;
authData["unionid"] = unionId; 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);
}
} }
} }