From b324d9812527eab18fa7d08b6be66b5f26d60ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A9=99=E5=AD=90?= <454313500@qq.com> Date: Thu, 30 Mar 2023 22:09:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=8C=E6=88=90=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/Yi.Framework.Sms.Aliyun/SmsAliyunManager.cs | 3 ++- .../module/Yi.Framework.Sms.Aliyun/SmsAliyunOptions.cs | 2 ++ .../src/project/BBS/Yi.BBS.Web/appsettings.json | 1 + .../src/project/bbs/Yi.BBS.Web/appsettings.json | 1 + .../Yi.RBAC.Application/Identity/AccountService.cs | 10 ++++++++-- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunManager.cs b/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunManager.cs index 07b248f5..3884740b 100644 --- a/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunManager.cs +++ b/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunManager.cs @@ -55,7 +55,8 @@ namespace Yi.Framework.Sms.Aliyun { PhoneNumbers = phoneNumbers, SignName = Options.SignName, - TemplateCode = code, + TemplateCode = Options.TemplateCode, + TemplateParam = System.Text.Json.JsonSerializer.Serialize(new { code }) }; var response = await AliyunClient.SendSmsAsync(sendSmsRequest); diff --git a/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunOptions.cs b/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunOptions.cs index 9ab63f3c..3d5c2d7a 100644 --- a/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunOptions.cs +++ b/Yi.Framework.Net6/src/module/Yi.Framework.Sms.Aliyun/SmsAliyunOptions.cs @@ -13,6 +13,8 @@ namespace Yi.Framework.Sms.Aliyun public string SignName { get; set; } + + public string TemplateCode { get; set; } public bool EnableFeature { get; set; } = true; } } diff --git a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/appsettings.json b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/appsettings.json index c41ff72f..43792456 100644 --- a/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/appsettings.json +++ b/Yi.Framework.Net6/src/project/BBS/Yi.BBS.Web/appsettings.json @@ -42,6 +42,7 @@ "AccessKeyId": "", "AccessKeySecret": "", "SignName": "", + "TemplateCode": "", "EnableFeature": false } } diff --git a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/appsettings.json b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/appsettings.json index c41ff72f..43792456 100644 --- a/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/appsettings.json +++ b/Yi.Framework.Net6/src/project/bbs/Yi.BBS.Web/appsettings.json @@ -42,6 +42,7 @@ "AccessKeyId": "", "AccessKeySecret": "", "SignName": "", + "TemplateCode": "", "EnableFeature": false } } diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs index 0a202aee..9a2f4cbb 100644 --- a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs @@ -172,13 +172,19 @@ namespace Yi.RBAC.Application.Identity /// 验证电话号码 /// /// - private void ValidationPhone(string str_handset) + private async Task ValidationPhone(string str_handset) { var res= Regex.IsMatch(str_handset, "^(0\\d{2,3}-?\\d{7,8}(-\\d{3,5}){0,1})|(((13[0-9])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(14[0-9]))\\d{8})$"); if (res == false) { throw new UserFriendlyException("手机号码格式错误!请检查"); } + if (await _userRepository.IsAnyAsync(x => x.Phone.ToString() == str_handset)) + { + throw new UserFriendlyException("该手机号已被注册!"); + + } + } @@ -189,7 +195,7 @@ namespace Yi.RBAC.Application.Identity [AllowAnonymous] public async Task PostCaptchaPhone(PhoneCaptchaImageDto input) { - ValidationPhone(input.Phone); + await ValidationPhone(input.Phone); var value = _cacheManager.Get($"Yi:Phone:{input.Phone}"); //防止暴刷