public ActionResult Index() { var user = ManagerProviderHelper.TryLogin(ManageProvider, HttpContext.RequestServices); if (user == null) { return(RedirectToAction("Login", "User", new { r = Request.GetEncodedPathAndQuery() //.Url.PathAndQuery })); } ViewBag.User = ManageProvider.User; ViewBag.Config = SysConfig.Current; // 工作台页面 var startPage = Request.GetRequestValue("page"); if (startPage.IsNullOrEmpty()) { startPage = Setting.Current.StartPage; } ViewBag.Main = startPage; ViewBag.Menus = GetMenu(); return(View()); }
/// <summary>授权核心</summary> /// <param name="httpContext"></param> /// <returns></returns> protected Boolean AuthorizeCore(Microsoft.AspNetCore.Http.HttpContext httpContext) { var prv = ManageProvider.Provider; var ctx = httpContext; // 判断当前登录用户 var user = ManagerProviderHelper.TryLogin(prv, httpContext.RequestServices); if (user == null) { return(false); } // 判断权限 if (!(ctx.Items["CurrentMenu"] is IMenu menu) || !(user is IUser user2)) { return(false); } return(user2.Has(menu, Permission)); }