コード例 #1
0
        public ActionResult Booking()
        {
            if (SessionUtility.GetBookingSession() == null || !SessionUtility.IsSessionAlive())
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
コード例 #2
0
        public ActionResult Login(string msg, string callUrl)
        {
            if (SessionUtility.IsSessionAlive())
            {
                return(RedirectToAction("Index", "Home"));
            }

            ViewData["msg"]     = msg;
            ViewData["callUrl"] = callUrl;

            return(View());
        }
コード例 #3
0
        public JsonResult AnyUserLogged()
        {
            var result = new JsonResult {
                ContentType = "text", Data = new { msg = "false" }
            };

            if (SessionUtility.IsSessionAlive())
            {
                result.Data = new { msg = "true" }
            }
            ;

            return(result);
        }
コード例 #4
0
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            var authorized = true;

            if (SessionUtility.IsSessionAlive()) //Only check authorize with user logged
            {
                if (string.IsNullOrEmpty(this.Roles) == false)
                {
                    var roles            = this.Roles.Split(' ');
                    var currentUserRoles = SessionUtility.GetLoggedUser().AccountType.Roles;
                    var rolesList        = currentUserRoles.Split(' ');

                    authorized = roles.Intersect(rolesList).Count() > 0;
                }
            }

            return(authorized);
        }
コード例 #5
0
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (NeedToCheckSession(filterContext))
            {
                if (SessionUtility.IsSessionAlive() == false)
                {
                    string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                    string actionName     = filterContext.ActionDescriptor.ActionName;
                    var    callBack       = controllerName + "/" + actionName;

                    filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
                    {
                        { "action", "Login" },
                        { "controller", "Account" },
                        { "Area", "Admin" },
                        { "callUrl", callBack }
                    });
                }
            }
        }