diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/BindInput.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/BindInput.cs index d821ebec..6468ab49 100644 --- a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/BindInput.cs +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/BindInput.cs @@ -5,4 +5,14 @@ public class BindInput public string JsCode { get; set; } public long Phone { get; set; } + + /// + /// 唯一标识码 + /// + public string? Uuid { get; set; } + + /// + /// 验证码 + /// + public string? Code { get; set; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/RegisterInput.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/RegisterInput.cs index 6e4db2e7..2f8609d8 100644 --- a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/RegisterInput.cs +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application.Contracts/Dtos/Account/RegisterInput.cs @@ -20,15 +20,17 @@ public class RegisterInput /// public string? Uuid { get; set; } + /// + /// 验证码 + /// + public string? Code { get; set; } + /// /// 电话 /// public long Phone { get; set; } - /// - /// 验证码 - /// - public string? Code { get; set; } + /// /// 昵称 diff --git a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Account/WeChatMiniProgramAccountService.cs b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Account/WeChatMiniProgramAccountService.cs index e309e958..42658ede 100644 --- a/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Account/WeChatMiniProgramAccountService.cs +++ b/Yi.Abp.Net8/module/digital-collectibles/Yi.Framework.DigitalCollectibles.Application/Services/Account/WeChatMiniProgramAccountService.cs @@ -65,6 +65,7 @@ public class WeChatMiniProgramAccountService : ApplicationService [HttpPost("wechat/mini-program/account/bind")] public async Task PostBindAsync(BindInput input) { + _accountService.ValidationImageCaptcha(input.Uuid,input.Code); //校验手机号与验证码 //根据手机号查询用户信息 //根据code去获取wxid diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs index 390e07de..6ce1b936 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs @@ -33,5 +33,10 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices /// Task PostCaptchaPhoneAsync(ValidationPhoneTypeEnum validationPhoneType, PhoneCaptchaImageDto input); + + /// + /// 校验图片登录验证码,无需和账号绑定 + /// + void ValidationImageCaptcha(string? uuid,string? code ); } } diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs index 1f08f654..af1f7dfe 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs @@ -81,8 +81,8 @@ namespace Yi.Framework.Rbac.Application.Services /// /// 校验图片登录验证码,无需和账号绑定 /// - [AllowAnonymous] - private void ValidationImageCaptcha(string? uuid,string? code ) + [RemoteService(isEnabled:false)] + public void ValidationImageCaptcha(string? uuid,string? code ) { if (_rbacOptions.EnableCaptcha) { @@ -207,7 +207,19 @@ namespace Yi.Framework.Rbac.Application.Services { return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.RetrievePassword, input); } - + + /// + /// 手机验证码-绑定 + /// + /// + /// + [HttpPost("account/captcha-phone/bind")] + [AllowAnonymous] + public async Task PostCaptchaPhoneForBindAsync(PhoneCaptchaImageDto input) + { + return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.Bind, input); + } + /// /// 手机验证码-需通过图形验证码 /// @@ -220,14 +232,12 @@ namespace Yi.Framework.Rbac.Application.Services ValidationImageCaptcha(input.Uuid,input.Code); await ValidationPhone(input.Phone); - - //注册的手机号验证,是不能已经注册过的 - //这里为了统一,绑定流程,不在次校验,而是在注册时校验 - // if (validationPhoneType == ValidationPhoneTypeEnum.Register && - // await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone)) - // { - // throw new UserFriendlyException("该手机号已被注册!"); - // } + + if (validationPhoneType == ValidationPhoneTypeEnum.Register && + await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone)) + { + throw new UserFriendlyException("该手机号已被注册!"); + } var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone)); diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Enums/ValidationPhoneTypeEnum.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Enums/ValidationPhoneTypeEnum.cs index 0446fb49..c69691d9 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Enums/ValidationPhoneTypeEnum.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain.Shared/Enums/ValidationPhoneTypeEnum.cs @@ -9,5 +9,9 @@ public enum ValidationPhoneTypeEnum /// /// 忘记密码 /// - RetrievePassword + RetrievePassword, + /// + /// 绑定 + /// + Bind } \ No newline at end of file