public async Task <IActionResult> Login([Bind] LoginViewModel model) { if (ModelState.IsValid) { var result = _authService.AccountLogin(model); if (result.IsSuccess) { var claims = new List <Claim> { new Claim(ClaimTypes.NameIdentifier, result.Username), new Claim(ClaimTypes.Name, model.Username) }; string action = "Index"; string controller = "Home"; if (result.RoleId == (int)RoleEnum.Member) { claims.Add(new Claim(ClaimTypes.Role, RoleEnum.Member.ToString())); } else { action = "Index"; controller = "Business"; claims.Add(new Claim(ClaimTypes.Role, RoleEnum.Salon.ToString())); } ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); return(RedirectToAction(action, controller)); } else { TempData["LoginStatus"] = "Login Failed.Please enter correct credentials"; return(View()); } } else { return(View()); } }