public async Task <JwtTokenVm> Handle(LoginCommand request, CancellationToken cancellationToken) { var result = await _signInManager.PasswordSignInAsync(request.Email, request.Password, false, false); if (!result.Succeeded) { throw new ApplicationException("INVALID_LOGIN_ATTEMPT"); } var user = await _userManager.FindByEmailAsync(request.Email); if (user == null) { throw new ApplicationException("INVALID_LOGIN_ATTEMPT"); } var secretKey = _config.GetValue <string>("Secret"); var tokenString = IdentityHelper.CreateClaimsWithToken(user.Email, secretKey); return(new JwtTokenVm { Email = user.Email, Token = tokenString }); }