修改User模块
This commit is contained in:
1 parent
d6471f97d3
commit
bb7162aaf6
21 files changed
+278
-336
No files matched your search
@@ -13,7 +13,6 @@ internal sealed class UserQueryService(IUserRepository repository) : IUserQueryS
|
||||
public async Task<UserInfo> GetUser(string userName)
|
||||
{
|
||||
RequestValidator.Validate(new UserNameRequest { UserName = userName?.Trim()! });
|
||||
UserInputChecks.Length(userName.Trim(), 20, "用户名");
|
||||
var user = await repository.GetUser(userName.Trim()) ?? throw new AppException("用户不存在");
|
||||
return new UserMapper().ToInfo(user);
|
||||
}
|
||||
@@ -27,7 +26,6 @@ internal sealed class UserAuthenticationService(IFreeSql orm, IUserQueryService
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
if (!RequestValidator.TryValidate(new UserLoginRequest { UserName = userName?.Trim()!, Password = password }, out _))
|
||||
return null;
|
||||
if (userName.Trim().Length > 20 || password.Length > 128) return null;
|
||||
var user = await orm.Select<UserEntity>().Where(u => u.UserName == userName.Trim()).FirstAsync(cancellationToken);
|
||||
if (user == null || !UserPassword.Verify(user, password)) return null;
|
||||
return await query.GetUser(user.UserName);
|
||||
|
||||
Reference in new issue
Block a user