public void OnAuthentication(AuthenticationContext filterContext) { var baseController = filterContext.Controller as BaseController; if (baseController != null) { if (baseController.IsLogin) { var exUser = baseController.ExUser; var ownedPermissions = exUser.OwnedPermissions ?? new List <Permission>(); if (this.RequiredPermissions.Any(t => !ownedPermissions.Contains(t))) { filterContext.RedirectToLogin(); } } else { filterContext.RedirectToLogin(); } } }
public void OnAuthentication(AuthenticationContext filterContext) { //这个方法是在Action执行之前调用 if (filterContext.HttpContext.Session != null) { var user = filterContext.HttpContext.Session[Const.SessionKey.LoginUser]; if (user == null) { filterContext.RedirectToLogin(); } } }