Exemple #1
0
        public static SiteConfiguration Set(HttpContext httpContext, string customerCode, int siteId, bool useFake)
        {
            //var useHierarchyRegionsFilter = _qpSettingsService.GetSetting(connectionString, "USE_HIERARCHY_REGIONS_FILTER");
            var config = new SiteConfiguration
            {
                SiteId = siteId,
                PublishStatusImageUrl = "/Content/icons/pub.png",
                CreatedStatusImageUrl = "/Content/icons/new.jpg"
            };

            httpContext.Items[StorageKey] = config;

            return(config);
        }
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            var httpContext = context.HttpContext;

            if (string.IsNullOrWhiteSpace(_webAppQpHelper.CustomerCode))
            {
                throw new Exception("Customer code should not be empty");
            }

            SiteConfiguration.Set(httpContext, _webAppQpHelper.CustomerCode, _webAppQpHelper.SiteId, _configuration.UseFake);

            var isAuthorize = _securityChecker.CheckAuthorization();

            var ci = new CultureInfo(httpContext.Session.GetString(QPSecurityChecker.UserLanguageKey) ?? QpLanguage.Default.GetDescription());

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;

            if (!isAuthorize)
            {
                context.Result = new UnauthorizedObjectResult(ApiResult.Fail(new Exception("Unauthorized")));
            }
        }