Beispiel #1
0
        /// <summary>
        /// 增加一个权限,get
        /// </summary>
        /// <returns></returns>
        public ActionResult AddRight()
        {
            Rights data = new Rights();
            string str  = string.Empty;

            try
            {
                string        userID   = SessionManager.UserID;
                string        rightUrl = this.Request.RawUrl;//"/User/AddRight";
                UserDbContext uc       = new UserDbContext("ConnStr1");
                bool          flag     = uc.IsUserHasRight(userID, rightUrl);

                if (flag)
                {
                    //str = "用户" + userID + "具有" + rightUrl + "权限";
                    return(View(data));
                }
                else
                {
                    str = "用户" + SessionManager.UserName + "不具有" + rightUrl + "权限";

                    string resStr = MisBase.MvcUT.ShowAlertAndHref(this, str, "Login");
                    return(Content(resStr));
                }
            }
            catch (Exception ex)
            {
                str = MisBase.BaseUT.GetRootException(ex).Message;
                string resStr = MisBase.MvcUT.ShowAlertAndHref(this, str, "Login");
                return(Content(resStr));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 判断用户是否有相关权限
        /// </summary>
        /// <returns></returns>
        public ActionResult UserHasRight()
        {
            string str = string.Empty;

            try
            {
                string        userID   = SessionManager.UserID;
                string        rightUrl = this.Request.RawUrl;//"/User/AddRight";
                UserDbContext uc       = new UserDbContext("ConnStr1");
                bool          flag     = uc.IsUserHasRight(userID, rightUrl);

                if (flag)
                {
                    str = "用户" + userID + "具有" + rightUrl + "权限";
                }
                else
                {
                    str = "用户" + userID + "不具有" + rightUrl + "权限";
                }
            }
            catch (Exception ex)
            {
                str = MisBase.BaseUT.GetRootException(ex).Message;
            }
            return(Content(str));
        }