public async Task <UserDetails> Handle(AuthenticateUserCommand request, CancellationToken cancellationToken) { var user = _context.Managers.FirstOrDefault(a => a.UserName == request.UserName.ToLower()); if (user == null) { return(null); } var isPasswordValid = user.Password == request.Password; if (!isPasswordValid) { return(null); } JwtSecurityToken jwtSecurityToken = await JwtHelper.GenerateJWToken(user, _jwtSettings); var jwtToken = new JwtSecurityTokenHandler().WriteToken(jwtSecurityToken); UserDetails userDetails = CustomMapper(user, jwtToken); return(await Task.FromResult(userDetails)); }