protected override void OnActionExecuting(ActionExecutingContext filterContext) { Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); //判断登录状态 if (LoginStatus == null || LoginStatus.IsLogin == false) { string returnUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/Member/MarkLoginInfo"; returnUrl = HttpUtility.UrlEncode(returnUrl, System.Text.Encoding.UTF8); string loginUrl = Lib4Net.Framework.Settings.SettingHelper.Instance.GetData("LoginUrl"); returnUrl = string.Format("{0}?redirectUrl={1}", loginUrl + "/Member/LoginOn", returnUrl); filterContext.Result = new RedirectResult(returnUrl); return; } //判断用户页面权限 string matchUrl = UrlMappingUtility.Instance.Match().MatchUrl.ToLower(); if (!MemCacheSDK.CheckPageRight(LoginStatus.UserName, LoginStatus.RoleID.Value, SettingHelper.Instance.GetData("SystemNo"), SettingHelper.Instance.GetData("GetValueUrl"), matchUrl)) { filterContext.Result = new RedirectResult("/Shared/NoPermission"); return; } base.OnActionExecuting(filterContext); }
public ActionResult MarkLoginInfo(string guid) { if (!string.IsNullOrEmpty(guid)) { MemCacheSDK.MarkLoginLocal(guid); } return(new RedirectResult("/system/index", false)); }
/// <summary> /// 注销 /// </summary> /// <returns></returns> public ActionResult LoginOut() { MemCacheSDK.LoginOut(SettingHelper.Instance.GetData("SystemNo"), MemCacheSDK.GetLoginStatus(SettingHelper.Instance.GetData("SystemNo"), SettingHelper.Instance.GetData("GetValueUrl")).UserName); string returnUrl = "http://" + System.Web.HttpContext.Current.Request.Url.Authority + "/Member/MarkLoginInfo"; string loginUrl = Lib4Net.Framework.Settings.SettingHelper.Instance.GetData("LoginUrl"); return(new RedirectResult(loginUrl + "/Member/loginOut?redirectUrl=" + returnUrl, false)); }
/// <summary> /// 用户导航菜单 /// </summary> /// <returns></returns> public ActionResult NavigateMenu() { if (LoginStatus.IsLogin) { ViewBag.MenuList = MemCacheSDK.GetUserMenuList(SettingHelper.Instance.GetData("SystemNo"), LoginStatus.UserName, LoginStatus.RoleID.Value, SettingHelper.Instance.GetData("GetValueUrl")); return(View()); } else { throw new Exception("未登录用户,请登录"); } }
public ActionResult Index() { if (LoginStatus.IsLogin) { List <MRolePermission> list = MemCacheSDK.GetUserMenuList(SettingHelper.Instance.GetData("SystemNo"), LoginStatus.UserName, LoginStatus.RoleID.Value, SettingHelper.Instance.GetData("GetValueUrl")); ViewBag.Modules = list; ViewBag.userName = LoginStatus.UserName; return(View()); } else { throw new Exception("未登录用户,请登录"); } }
public ActionResult LoginOn(string userName, string password) { if (MemCacheSDK.GetLoginStatus(SettingHelper.Instance.GetData("SystemNo"), SettingHelper.Instance.GetData("GetValueUrl")).IsLogin) { MemCacheSDK.LoginOut(SettingHelper.Instance.GetData("SystemNo"), MemCacheSDK.GetLoginStatus(SettingHelper.Instance.GetData("SystemNo"), SettingHelper.Instance.GetData("GetValueUrl")).UserName); } if (!LoginService.Instance.UserEnabled(userName)) { ModelState.AddModelError("SummaryError", "用户不存在或被禁用"); return(View()); } bool retLogin = LoginService.Instance.LoginOn(userName.ToLowerInvariant(), password); if (retLogin) { string redirectUrl = "/system/index"; //?url=" + RedirectBack(userName); return(new RedirectResult(redirectUrl, false)); } ModelState.AddModelError("SummaryError", "用户名或密码输入错误"); ViewBag.UserName = userName; return(View()); }