Esempio n. 1
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var person = _loggedInHelper.GetLoggedInPerson();

            if (string.IsNullOrEmpty(person.Email))
            {
                context.Result = new RedirectResult(_configuration.GetMyAccountUrl() + "?returnUrl=" + context.HttpContext.Request.GetUri(), false);
            }

            context.ActionArguments["loggedInPerson"] = person;
        }
Esempio n. 2
0
        public async Task <Document> GetSecureDocument(string assetId, string groupSlug)
        {
            var url = _urlGeneratorSimple.BaseContentApiUrl <Document>().AddSlug($"{groupSlug}/{assetId}");

            var loggedInPerson = _loggedInHelper.GetLoggedInPerson();

            if (string.IsNullOrEmpty(loggedInPerson.Email))
            {
                _logger.LogWarning($"Document {assetId} was requested, but the user wasn't logged in");
                return(null);
            }

            AddHeader("jwtCookie", loggedInPerson.rawCookie);
            return(await GetResponseAsync <Document>(url));
        }
        public async Task <Document> GetSecureDocumentByAssetId(string businessId, string assetId, string groupSlug)
        {
            var config = _contentfulConfigBuilder.Build(businessId);
            var user   = _loggedInHelper.GetLoggedInPerson();

            var hasPermission = await IsUserAdvisorForGroup(groupSlug, config, user);

            if (!hasPermission)
            {
                return(null);
            }

            var asset = await GetDocumentAsAsset(assetId, config);

            return(asset == null || !await DoesGroupReferenceAsset(groupSlug, config, asset)
                ? null
                : _documentFactory.ToModel(asset));
        }