feat: 补充绑定逻辑

This commit is contained in:
橙子
2024-10-21 23:35:10 +08:00
parent 1a73f7bef3
commit 0e6d380b7e
6 changed files with 48 additions and 16 deletions

View File

@@ -5,4 +5,14 @@ public class BindInput
public string JsCode { get; set; }
public long Phone { get; set; }
/// <summary>
/// 唯一标识码
/// </summary>
public string? Uuid { get; set; }
/// <summary>
/// 验证码
/// </summary>
public string? Code { get; set; }
}

View File

@@ -20,15 +20,17 @@ public class RegisterInput
/// </summary>
public string? Uuid { get; set; }
/// <summary>
/// 验证码
/// </summary>
public string? Code { get; set; }
/// <summary>
/// 电话
/// </summary>
public long Phone { get; set; }
/// <summary>
/// 验证码
/// </summary>
public string? Code { get; set; }
/// <summary>
/// 昵称

View File

@@ -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

View File

@@ -33,5 +33,10 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices
/// <returns></returns>
Task<object> PostCaptchaPhoneAsync(ValidationPhoneTypeEnum validationPhoneType,
PhoneCaptchaImageDto input);
/// <summary>
/// 校验图片登录验证码,无需和账号绑定
/// </summary>
void ValidationImageCaptcha(string? uuid,string? code );
}
}

View File

@@ -81,8 +81,8 @@ namespace Yi.Framework.Rbac.Application.Services
/// <summary>
/// 校验图片登录验证码,无需和账号绑定
/// </summary>
[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);
}
/// <summary>
/// 手机验证码-绑定
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("account/captcha-phone/bind")]
[AllowAnonymous]
public async Task<object> PostCaptchaPhoneForBindAsync(PhoneCaptchaImageDto input)
{
return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.Bind, input);
}
/// <summary>
/// 手机验证码-需通过图形验证码
/// </summary>
@@ -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));

View File

@@ -9,5 +9,9 @@ public enum ValidationPhoneTypeEnum
/// <summary>
/// 忘记密码
/// </summary>
RetrievePassword
RetrievePassword,
/// <summary>
/// 绑定
/// </summary>
Bind
}