feat: 支持手机号为空的临时账号

This commit is contained in:
橙子
2024-10-26 10:21:16 +08:00
parent 254975fcd3
commit 779e84213e
5 changed files with 13 additions and 8 deletions

View File

@@ -23,7 +23,7 @@
/// <summary>
/// 电话
/// </summary>
public long Phone { get; set; }
public long? Phone { get; set; }
/// <summary>
/// 验证码

View File

@@ -317,17 +317,22 @@ namespace Yi.Framework.Rbac.Application.Services
throw new UserFriendlyException("该系统暂未开放注册功能");
}
if (_rbacOptions.EnableCaptcha)
if (input.Phone is null)
{
//校验验证码,根据电话号码获取 value比对验证码已经uuid
await ValidationPhoneCaptchaAsync(ValidationPhoneTypeEnum.Register, input.Phone, input.Code);
throw new UserFriendlyException("手机号不能为空");
}
//临时账号
if (input.UserName.StartsWith("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);
}

View File

@@ -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;
EncryPassword.Password = password;

View File

@@ -272,7 +272,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
/// <param name="password"></param>
/// <param name="phone"></param>
/// <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);
await _userManager.CreateAsync(user);

View File

@@ -14,7 +14,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
string CreateRefreshToken(Guid userId);
Task<string> GetTokenByUserIdAsync(Guid userId,Action<UserRoleMenuDto>? getUserInfo=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 UpdatePasswordAsync(Guid userId, string newPassword, string oldPassword);
}