Esempio n. 1
0
        /// <summary>
        /// OnActionExecuting
        /// </summary>
        /// <param name="filterContext">filterContext</param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            //if (!filterContext.IsChildAction)
            //{
            MenuCode = (string)filterContext.HttpContext.Items["MenuCode"];
            AuthT = (AuthT)filterContext.HttpContext.Items["AuthT"];
            //}

            HttpRequestBase req = filterContext.HttpContext.Request;
            HttpResponseBase res = filterContext.HttpContext.Response;
            string url = req.Url.ToString().ToLower();

            #if DEBUG
            #else
            //if (url.IndexOf("http://metrology.kr") != -1)
            //{
            //   url = url.Replace("http://metrology.kr", "http://www.metrology.kr");
            //    res.Redirect(url);
            //}
            #endif
        }
Esempio n. 2
0
        /*
        */
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            IsLogin = base.AuthorizeCore(httpContext);

            //파라미터로 넘기는 menuCode를 받는다.[하나의 URL로 여러개의 메뉴를 다루는 곳에서 권한인증을 위해 설정]
            if (MenuCode == "PARAM_CHECK" || !String.IsNullOrEmpty(httpContext.Request["menuCode"]))
            {
                string checkMenuCode = httpContext.Request["menuCode"];//httpContext.Request.Params.Get("menuCode");
                if (checkMenuCode != null)
                {
                    MenuCode = checkMenuCode;
                }
            }

            httpContext.Items["MenuCode"] = MenuCode;

            // 메뉴코드 통계INSERT
            //new StatsBiz().ProcessStatsMenuCount(MenuCode);

            if (IsLogin == true)
            {
                bool bIsAuth = true;

                try
                {
                    if (BootstrapCertification.User == null || BootstrapCertification.User.UserId == null)
                    {
                        BootstrapCertification.SignOut();
                        IsLogin = false;
                        bIsAuth = false;
                    }
                    else
                    {
                        // MenuCode 에 해당하는 사용자의 권한목록을 DB에서 조회
                        UserMenuAuthSearchT userMenuAuthSearchT = new UserMenuAuthSearchT();
                        userMenuAuthSearchT.MenuCode            = MenuCode; //메뉴ID
                        userMenuAuthSearchT.UserId              = BootstrapCertification.User.UserId; //사용자ID
                        userMenuAuthSearchT.UserSeCode          = BootstrapCertification.User.UserSeCode; //사용자구분코드
                        userMenuAuthSearchT.AuthorGroupList     = BootstrapCertification.User.AuthorGroupList; //권한그룹목록

                        IList<string> authList = new ProfileBiz().SelectUserMenuAuthList(userMenuAuthSearchT);

                        // 해당 메뉴의 사용권한을 저장
                        AuthT authT = new AuthT();
                        if (authList != null && authList.Count > 0)
                        {
                            authT.IsRead = authList.Contains("AC006001");
                            authT.IsCreate = authList.Contains("AC006002");
                            authT.IsUpdate = authList.Contains("AC006003");
                            authT.IsDelete = authList.Contains("AC006004");
                            authT.IsPrint = authList.Contains("AC006005");
                            authT.IsAdmin = authList.Contains("AC006006");
                        }

                        httpContext.Items["AuthT"] = authT;

                        // 체크할 기능권한이 있으면 Security
                        //List<Authorize> authotizeList = Security.Security.AuthorizeTypeChange(authList.ToList());
                        List<Authorize> authotizeList = Security.AuthorizeTypeChange(authList.ToList());
                        if (CheckAuth != null)
                        {
                            // 권한이 존재하는지 체크
                            bool isAllHave = true;

                            foreach (Authorize checkauthotize in CheckAuth)
                            {
                                bool isHave = false;

                                foreach (Authorize userAuthotize in authotizeList)
                                {
                                    if (checkauthotize == userAuthotize)
                                    {
                                        isHave = true;
                                    }
                                }

                                if (isHave == false)
                                {
                                    isAllHave = false;
                                }
                            }

                            if (isAllHave == false)
                            {
                                bIsAuth = false;
                            }
                        }

                        if (bIsAuth)
                        {
                            //사용자접속통계 INSERT
                            if (BootstrapCertification.User.UserSeCode == "AC007003" || BootstrapCertification.User.UserSeCode == "AC007004" || BootstrapCertification.User.UserSeCode == "AC007005")
                            {
                                //new EmplyrConectHistBiz().InsertEmplyrConectHist(MenuCode, BootstrapCertification.User);
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }

            #if DEBUG
                if (BootstrapCertification.User.UserId == "system" || BootstrapCertification.User.UserId == "entr01")
                {
                    bIsAuth = true;
                }
            #endif
                return bIsAuth;
            }
            else
            {
                if (IsLoginNeed == true)
                {
                    return IsLogin;
                }
                else
                {
                    return true;
                }
            }
        }