feat: 支持手机号为空的临时账号
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 电话
|
/// 电话
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long Phone { get; set; }
|
public long? Phone { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证码
|
/// 验证码
|
||||||
|
|||||||
@@ -317,17 +317,22 @@ namespace Yi.Framework.Rbac.Application.Services
|
|||||||
throw new UserFriendlyException("该系统暂未开放注册功能");
|
throw new UserFriendlyException("该系统暂未开放注册功能");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rbacOptions.EnableCaptcha)
|
if (input.Phone is null)
|
||||||
{
|
{
|
||||||
//校验验证码,根据电话号码获取 value,比对验证码已经uuid
|
throw new UserFriendlyException("手机号不能为空");
|
||||||
await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.Register, input.Phone, input.Code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//临时账号
|
//临时账号
|
||||||
if (input.UserName.StartsWith("ls_"))
|
if (input.UserName.StartsWith("ls_"))
|
||||||
{
|
{
|
||||||
throw new UserFriendlyException("注册账号不能以ls_字符开头");
|
throw new UserFriendlyException("注册账号不能以ls_字符开头");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_rbacOptions.EnableCaptcha)
|
||||||
|
{
|
||||||
|
//校验验证码,根据电话号码获取 value,比对验证码已经uuid
|
||||||
|
await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.Register, input.Phone.Value, input.Code);
|
||||||
|
}
|
||||||
|
|
||||||
//注册领域逻辑
|
//注册领域逻辑
|
||||||
await _accountManager.RegisterAsync(input.UserName, input.Password, input.Phone, input.Nick);
|
await _accountManager.RegisterAsync(input.UserName, input.Password, input.Phone, input.Nick);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Yi.Framework.Rbac.Domain.Entities
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public UserAggregateRoot(string userName, string password, long phone, string? nick = null)
|
public UserAggregateRoot(string userName, string password, long? phone, string? nick = null)
|
||||||
{
|
{
|
||||||
UserName = userName;
|
UserName = userName;
|
||||||
EncryPassword.Password = password;
|
EncryPassword.Password = password;
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
|
|||||||
/// <param name="password"></param>
|
/// <param name="password"></param>
|
||||||
/// <param name="phone"></param>
|
/// <param name="phone"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task RegisterAsync(string userName, string password, long phone,string? nick)
|
public async Task RegisterAsync(string userName, string password, long? phone,string? nick)
|
||||||
{
|
{
|
||||||
var user = new UserAggregateRoot(userName, password, phone,nick);
|
var user = new UserAggregateRoot(userName, password, phone,nick);
|
||||||
await _userManager.CreateAsync(user);
|
await _userManager.CreateAsync(user);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
|
|||||||
string CreateRefreshToken(Guid userId);
|
string CreateRefreshToken(Guid userId);
|
||||||
Task<string> GetTokenByUserIdAsync(Guid userId,Action<UserRoleMenuDto>? getUserInfo=null);
|
Task<string> GetTokenByUserIdAsync(Guid userId,Action<UserRoleMenuDto>? getUserInfo=null);
|
||||||
Task LoginValidationAsync(string userName, string password, Action<UserAggregateRoot>? userAction = null);
|
Task LoginValidationAsync(string userName, string password, Action<UserAggregateRoot>? userAction = null);
|
||||||
Task RegisterAsync(string userName, string password, long phone,string? nick);
|
Task RegisterAsync(string userName, string password, long? phone,string? nick);
|
||||||
Task<bool> RestPasswordAsync(Guid userId, string password);
|
Task<bool> RestPasswordAsync(Guid userId, string password);
|
||||||
Task UpdatePasswordAsync(Guid userId, string newPassword, string oldPassword);
|
Task UpdatePasswordAsync(Guid userId, string newPassword, string oldPassword);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user