Ejemplo n.º 1
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            string currentActionName = (context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)?.ActionName;

            if (!string.IsNullOrEmpty(currentActionName) && currentActionName.ToUpperInvariant().StartsWith("GET"))
            {
                return;
            }

            string sessionStr = context.HttpContext?.Session?.GetString(Constant.Session.SessionCurrentUser);

            Layer.Models.Account.PegaUser user = string.IsNullOrEmpty(sessionStr) ? null : Utilities.Deserialize <Layer.Models.Account.PegaUser>(sessionStr);

            if (user == null || user.Username?.ToUpper() == "DEMOUSER")
            {
                context.Result = ActionURL.RedirectTo("NotValidWriteUser", "Account");
            }
        }
Ejemplo n.º 2
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            string currentActionName = (context.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)?.ActionName;

            if (currentActionName == "ViewPortfolio" || currentActionName == "LoadPortfolioViewMode")
            {
                return;
            }

            if (context.HttpContext == null || !context.HttpContext.Session.IsAvailable ||
                string.IsNullOrEmpty(context.HttpContext.Session.GetString(Constant.Session.SessionCurrentUser)))
            {
                context.Result = context.HttpContext != null && context.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest" // IsAjax()
                                 ? ActionURL.RedirectTo("SessionTimeout", "Account") :
                                 new RedirectToRouteResult(new RouteValueDictionary
                {
                    { "Action", "Index" },
                    { "Controller", "Home" },
                    { "timeout", "true" }
                });
            }
        }