public async Task <IActionResult> SignIn(UserViewModel model) { Token token = await _testApiService.SignIn(model); if (token != null) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, token.User.Name), new Claim(ClaimTypes.Surname, token.User.Surname), new Claim(ClaimTypes.Role, "member"), new Claim("apitoken", token.AccessToken) }; var userIdentity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role); userIdentity.AddClaims(claims); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal, new AuthenticationProperties { IsPersistent = true }); return(RedirectToAction("TestPage")); } else { ModelState.AddModelError("", "Hatalı kullanıcı adı ya da şifre"); return(View(model)); } }