public async Task <IActionResult> Authorize([FromBody] LoginModel loginModel) { var tokenWithClaimsPrincipal = _tokenGenerator.GenerateAccessTokenIfIdentityConfirmed( loginModel.Username, loginModel.Password); if (!string.IsNullOrWhiteSpace(tokenWithClaimsPrincipal.AccessToken)) { AuthenticationProperties authProps = new AuthenticationProperties(); authProps.Items.Add(new KeyValuePair <string, string>("jwt", tokenWithClaimsPrincipal.AccessToken)); await HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, tokenWithClaimsPrincipal.ClaimsPrincipal, authProps); return(new JsonResult(new { success = true })); } else { return(BadRequest()); } }