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