public async Task <IActionResult> Login(LoginModel model) { if (!ModelState.IsValid) { return(View()); } var res = await _auth.Authentificate(model.Email, model.Password); if (res == null) { ViewBag.IsWrongLogin = true as bool?; return(View("Login")); } var identity = new ClaimsIdentity(res.Claims, CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignInAsync("CookieAuthenticationDefaults.AuthenticationScheme", new ClaimsPrincipal(identity)); return(RedirectToPage("/Profile/Profile")); }