public async Task <IActionResult> YetkiliLogin(LoginModel model) { if (ModelState.IsValid) { if (model.kullaniciTur == "2") { var personel = _personelService.LoginCont(model.aboneNo, model.parola); if (personel != null) { Console.WriteLine("operator kntrolde"); var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.aboneNo), new Claim("gorevturu", "operatör") }; var userIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); Console.WriteLine("operator" + userIdentity.Name); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); Console.WriteLine("operator" + principal.ToString()); HttpContext.SignInAsync(principal).Wait(); return(RedirectToAction("Index", "Operator", personel)); } } else if (model.kullaniciTur == "3") { var personel = _personelService.LoginCont(model.aboneNo, model.parola); if (personel != null && personel.GorevTur == "yönetici") { var claims = new List <Claim> { new Claim(ClaimTypes.Name, model.aboneNo), new Claim("gorevturu", "yönetici") }; var userIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(principal); return(RedirectToAction("Index", "Admin", personel)); } } } if (!ModelState.IsValid) // Bilgiler Eksikse { ModelState.AddModelError("Sonuc", "Giriş Bilgileriniz Hatalı..."); return(View(model1)); } ModelState.AddModelError("Sonuc", "Giriş Bilgileriniz Hatalı..."); return(View(model1)); }