public async Task <IActionResult> Login(UserManager loggedUser) { if (!isValidAuth(loggedUser.Name, loggedUser.Password)) { return(View()); } else { loggedUser.AdminId = adminUserRepository.First(x => x.Name == loggedUser.Name && x.Password == loggedUser.Password).AdminUserId; } List <Claim> claims = new List <Claim> { new Claim(ClaimTypes.Name, "Admin"), new Claim(ClaimTypes.Name, loggedUser.Name), new Claim(ClaimTypes.NameIdentifier, loggedUser.AdminId.ToString()) }; var scheme = CookieAuthenticationDefaults.AuthenticationScheme; ClaimsIdentity claimsIdentity = new ClaimsIdentity(claims, scheme); ClaimsPrincipal principal = new ClaimsPrincipal(claimsIdentity); await HttpContext.SignInAsync(scheme, principal); this.user.Name = loggedUser.Name; this.user.Password = loggedUser.Password; this.user.AdminId = loggedUser.AdminId; return(RedirectToAction("Index", "AdminUser", this.user)); }