// GET: Admin public ActionResult Index() { var ses = Session["Token"]; if (ses == null) { return(RedirectToAction("Unauthorize", "Login")); } string token = ses.ToString(); if (token != null) { var role = new JwtSecurityTokenHandler().ReadJwtToken(token).Claims.Where(p => p.Type == "Role").FirstOrDefault()?.Value; if (role.Equals("Manager") || role.Equals("Staff")) { return(View()); } } return(RedirectToAction("Unauthorize", "Login")); }
public IActionResult Index() { string token = HttpContext.Session.GetString("UserToken"); if (!string.IsNullOrWhiteSpace(token)) { var readToken = new JwtSecurityTokenHandler().ReadJwtToken(token).Claims.FirstOrDefault(x => x.Type.Equals("role")).Value; if (readToken.Equals("Admin")) { return(RedirectToAction("Index", "Departments", null, null)); } } return(View()); }