feat: 补充绑定逻辑
This commit is contained in:
@@ -5,4 +5,14 @@ public class BindInput
|
|||||||
public string JsCode { get; set; }
|
public string JsCode { get; set; }
|
||||||
|
|
||||||
public long Phone { get; set; }
|
public long Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 唯一标识码
|
||||||
|
/// </summary>
|
||||||
|
public string? Uuid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证码
|
||||||
|
/// </summary>
|
||||||
|
public string? Code { get; set; }
|
||||||
}
|
}
|
||||||
@@ -20,15 +20,17 @@ public class RegisterInput
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string? Uuid { get; set; }
|
public string? Uuid { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证码
|
||||||
|
/// </summary>
|
||||||
|
public string? Code { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 电话
|
/// 电话
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long Phone { get; set; }
|
public long Phone { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 验证码
|
|
||||||
/// </summary>
|
|
||||||
public string? Code { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 昵称
|
/// 昵称
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class WeChatMiniProgramAccountService : ApplicationService
|
|||||||
[HttpPost("wechat/mini-program/account/bind")]
|
[HttpPost("wechat/mini-program/account/bind")]
|
||||||
public async Task PostBindAsync(BindInput input)
|
public async Task PostBindAsync(BindInput input)
|
||||||
{
|
{
|
||||||
|
_accountService.ValidationImageCaptcha(input.Uuid,input.Code);
|
||||||
//校验手机号与验证码
|
//校验手机号与验证码
|
||||||
//根据手机号查询用户信息
|
//根据手机号查询用户信息
|
||||||
//根据code去获取wxid
|
//根据code去获取wxid
|
||||||
|
|||||||
@@ -33,5 +33,10 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<object> PostCaptchaPhoneAsync(ValidationPhoneTypeEnum validationPhoneType,
|
Task<object> PostCaptchaPhoneAsync(ValidationPhoneTypeEnum validationPhoneType,
|
||||||
PhoneCaptchaImageDto input);
|
PhoneCaptchaImageDto input);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 校验图片登录验证码,无需和账号绑定
|
||||||
|
/// </summary>
|
||||||
|
void ValidationImageCaptcha(string? uuid,string? code );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,8 @@ namespace Yi.Framework.Rbac.Application.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 校验图片登录验证码,无需和账号绑定
|
/// 校验图片登录验证码,无需和账号绑定
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
[RemoteService(isEnabled:false)]
|
||||||
private void ValidationImageCaptcha(string? uuid,string? code )
|
public void ValidationImageCaptcha(string? uuid,string? code )
|
||||||
{
|
{
|
||||||
if (_rbacOptions.EnableCaptcha)
|
if (_rbacOptions.EnableCaptcha)
|
||||||
{
|
{
|
||||||
@@ -207,7 +207,19 @@ namespace Yi.Framework.Rbac.Application.Services
|
|||||||
{
|
{
|
||||||
return await PostCaptchaPhoneAsync(ValidationPhoneTypeEnum.RetrievePassword, input);
|
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>
|
||||||
/// 手机验证码-需通过图形验证码
|
/// 手机验证码-需通过图形验证码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -220,14 +232,12 @@ namespace Yi.Framework.Rbac.Application.Services
|
|||||||
ValidationImageCaptcha(input.Uuid,input.Code);
|
ValidationImageCaptcha(input.Uuid,input.Code);
|
||||||
|
|
||||||
await ValidationPhone(input.Phone);
|
await ValidationPhone(input.Phone);
|
||||||
|
|
||||||
//注册的手机号验证,是不能已经注册过的
|
if (validationPhoneType == ValidationPhoneTypeEnum.Register &&
|
||||||
//这里为了统一,绑定流程,不在次校验,而是在注册时校验
|
await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone))
|
||||||
// if (validationPhoneType == ValidationPhoneTypeEnum.Register &&
|
{
|
||||||
// await _userRepository.IsAnyAsync(x => x.Phone.ToString() == input.Phone))
|
throw new UserFriendlyException("该手机号已被注册!");
|
||||||
// {
|
}
|
||||||
// throw new UserFriendlyException("该手机号已被注册!");
|
|
||||||
// }
|
|
||||||
|
|
||||||
var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone));
|
var value = await _phoneCache.GetAsync(new CaptchaPhoneCacheKey(validationPhoneType, input.Phone));
|
||||||
|
|
||||||
|
|||||||
@@ -9,5 +9,9 @@ public enum ValidationPhoneTypeEnum
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忘记密码
|
/// 忘记密码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
RetrievePassword
|
RetrievePassword,
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定
|
||||||
|
/// </summary>
|
||||||
|
Bind
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user