File was renamed from FlexJobApi.User.Application/Auths/Commands/AuthPasswordLoginCommandHandler.cs |
| | |
| | | /// <summary> |
| | | /// 密码登录 |
| | | /// </summary> |
| | | public class AuthPasswordLoginCommandHandler( |
| | | public class PasswordLoginCommandHandler( |
| | | IRepository<UserAuth> userAuthRep, |
| | | IRepository<UserInfo> userInfoRep) |
| | | : IRequestHandler<AuthPasswordLoginCommand, AuthPasswordLoginCallback> |
| | | : IRequestHandler<PasswordLoginCommand, PasswordLoginCommandCallback> |
| | | { |
| | | private readonly IRepository<UserAuth> userAuthRep = userAuthRep; |
| | | private readonly IRepository<UserInfo> userInfoRep = userInfoRep; |
| | | |
| | | /// <inheritdoc/> |
| | | public async Task<AuthPasswordLoginCallback> Handle(AuthPasswordLoginCommand request, CancellationToken cancellationToken) |
| | | public async Task<PasswordLoginCommandCallback> Handle(PasswordLoginCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var userInfo = await userInfoRep.AsQueryable().AsNoTracking() |
| | | .Include(it => it.UserAuth) |
| | |
| | | it.UserAuth.Password |
| | | }) |
| | | .FirstOrDefaultAsync(cancellationToken); |
| | | if (userInfo == null) throw Oops.Oh(EnumUserErrorCodeType.u1000); |
| | | if (!PBKDF2Encryption.Compare(request.Password, userInfo.Password)) throw Oops.Oh(EnumUserErrorCodeType.u1000); |
| | | if (userInfo == null |
| | | || !PBKDF2Encryption.Compare(request.Password, userInfo.Password)) |
| | | throw Oops.Oh(EnumUserErrorCodeType.u1000); |
| | | |
| | | var logier = new CurrentLogier |
| | | { |
| | | UserInfoId = userInfo.Id, |
| | |
| | | PhoneNumber = userInfo.PhoneNumber, |
| | | }; |
| | | JwtUtils.GenerateToken(logier); |
| | | return new AuthPasswordLoginCallback(); |
| | | |
| | | return new PasswordLoginCommandCallback(); |
| | | } |
| | | } |
| | | } |