public async Task <IActionResult> LogInAsync([FromBody] FacebookLoginData data) { var account = await _fb.GetAccountAsync(data.AccessToken, "email"); if (account.ContainsKey("error") || !account.ContainsKey("email")) { return(StatusCode(StatusCodes.Status401Unauthorized)); } string email = (string)account["email"]; User user = await _db.GetUserAsync(email, registerIfMissing : true); var identity = new ClaimsIdentity(new Claim[] { new Claim("Email", email) }); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); return(new JsonResult(new { success = true })); }