From b1d1a3c77c5d0a52b82d626681e468d40f23a45d Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 14 Jul 2020 11:51:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E9=AA=8C=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Storage/Storage.Test/UserTest.cs | 12 +++++++++++ Storage/Storage/LCUser.cs | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/Storage/Storage.Test/UserTest.cs b/Storage/Storage.Test/UserTest.cs index 53c9f7be..56cfaca9 100644 --- a/Storage/Storage.Test/UserTest.cs +++ b/Storage/Storage.Test/UserTest.cs @@ -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"); + } } } diff --git a/Storage/Storage/LCUser.cs b/Storage/Storage/LCUser.cs index b86001be..bfd21dbf 100644 --- a/Storage/Storage/LCUser.cs +++ b/Storage/Storage/LCUser.cs @@ -555,5 +555,39 @@ static void MergeAuthData(Dictionary authData, string unionId, L authData["main_account"] = option.AsMainAccount; authData["unionid"] = unionId; } + + /// + /// 请求修改手机号验证码 + /// + /// + /// + /// + /// + public static async Task RequestSMSCodeForUpdatingPhoneNumber(string mobile, int ttl = 360, string captchaToken = null) { + string path = "requestChangePhoneNumber"; + Dictionary data = new Dictionary { + { "mobilePhoneNumber", mobile }, + { "ttl", ttl } + }; + if (!string.IsNullOrEmpty(captchaToken)) { + data["validate_token"] = captchaToken; + } + await LCApplication.HttpClient.Post>(path, data: data); + } + + /// + /// 验证修改手机号验证码 + /// + /// + /// + /// + public static async Task VerifyCodeForUpdatingPhoneNumber(string mobile, string code) { + string path = "changePhoneNumber"; + Dictionary data = new Dictionary { + { "mobilePhoneNumber", mobile }, + { "code", code } + }; + await LCApplication.HttpClient.Post>(path, data: data); + } } }