コード例 #1
0
        //EndDocSection:Constructor

        //DocSection:DisplayConsent
        public ActionResult DisplayConsent()
        {
            // Gets the related tracking consent
            // Fill in the code name of the appropriate consent object in Xperience
            ConsentInfo consent = consentInfoProvider.Get("SampleTrackingConsent");

            // Gets the current contact
            ContactInfo currentContact = ContactManagementContext.GetCurrentContact();

            // Sets the default cookie level for contacts who have revoked the tracking consent
            // Required for scenarios where one contact uses multiple browsers
            if ((currentContact != null) && !consentAgreementService.IsAgreed(currentContact, consent))
            {
                var defaultCookieLevel = currentCookieLevelProvider.GetDefaultCookieLevel();
                currentCookieLevelProvider.SetCurrentCookieLevel(defaultCookieLevel);
            }

            var consentModel = new TrackingConsentViewModel
            {
                // Adds the consent's short text to the model
                ShortText = consent.GetConsentText("en-US").ShortText,

                // Checks whether the current contact has given an agreement for the tracking consent
                IsAgreed = (currentContact != null) && consentAgreementService.IsAgreed(currentContact, consent)
            };

            return(View("Consent", consentModel));
        }
コード例 #2
0
        /// <summary>
        /// Constructor.
        /// You can use a dependency injection container to initialize required services and providers.
        /// </summary>
        public RegisterWithConsentController(IEventLogService eventLogService,
                                             IFormConsentAgreementService formConsentAgreementService,
                                             IUserInfoProvider userInfoProvider,
                                             IConsentInfoProvider consentInfoProvider)
        {
            this.eventLogService             = eventLogService;
            this.formConsentAgreementService = formConsentAgreementService;
            this.userInfoProvider            = userInfoProvider;

            // Gets the related consent
            // Fill in the code name of the appropriate consent object in Kentico
            consent = consentInfoProvider.Get("SampleRegistrationConsent");
        }
コード例 #3
0
        // GET: Consent
        public ActionResult Index()
        {
            var consent = consentInfoProvider.Get(TrackingConsentGenerator.CONSENT_NAME);

            if (consent != null)
            {
                var model = new ConsentViewModel
                {
                    ConsentShortText = consent.GetConsentText(Thread.CurrentThread.CurrentUICulture.Name).ShortText
                };

                var contact = ContactManagementContext.CurrentContact;
                if ((contact != null) && consentAgreementService.IsAgreed(contact, consent))
                {
                    model.IsConsentAgreed = true;
                }

                return(PartialView("_TrackingConsent", model));
            }

            return(new EmptyResult());
        }
コード例 #4
0
        public ActionResult Revoke(string consentName)
        {
            var consentToRevoke = consentInfoProvider.Get(consentName);

            if (consentToRevoke != null && CurrentContact != null)
            {
                consentAgreementService.Revoke(CurrentContact, consentToRevoke);

                if (consentName == TrackingConsentGenerator.CONSENT_NAME)
                {
                    cookieLevelProvider.SetCurrentCookieLevel(cookieLevelProvider.GetDefaultCookieLevel());
                    ExecuteRevokeTrackingConsentTask(siteService.CurrentSite, CurrentContact);
                }

                TempData[SUCCESS_RESULT] = true;
            }
            else
            {
                TempData[ERROR_RESULT] = true;
            }

            return(Redirect(Url.Kentico().PageUrl(ContentItemIdentifiers.PRIVACY)));
        }
コード例 #5
0
        /// <summary>
        /// Constructor.
        /// You can use a dependency injection container to initialize the consent agreement service.
        /// </summary>
        public RegisterWithConsentController(IFormConsentAgreementService formConsentAgreementService,
                                             SignInManager <ApplicationUser> signInManager,
                                             ApplicationUserManager <ApplicationUser> userManager,
                                             IEventLogService eventLogService,
                                             IConsentInfoProvider consentInfoProvider)
        {
            this.formConsentAgreementService = formConsentAgreementService;
            this.signInManager   = signInManager;
            this.userManager     = userManager;
            this.eventLogService = eventLogService;

            // Gets the related consent
            // Fill in the code name of the appropriate consent object in Xperience
            consent = consentInfoProvider.Get("SampleRegistrationConsent");
        }
コード例 #6
0
        public ActionResult Agree(string returnUrl)
        {
            var consent = consentInfoProvider.Get(TrackingConsentGenerator.CONSENT_NAME);

            if (consent != null)
            {
                cookieLevelProvider.SetCurrentCookieLevel(CookieLevel.All);

                var contact = ContactManagementContext.CurrentContact;
                if (contact != null)
                {
                    consentAgreementService.Agree(contact, consent);
                }

                return(Redirect(returnUrl));
            }

            return(new StatusCodeResult(StatusCodes.Status400BadRequest));
        }
コード例 #7
0
        public ActionResult Revoke(int consentId)
        {
            // Gets the related consent object
            ConsentInfo consent = consentInfoProvider.Get(consentId);

            // Gets the current visitor's contact
            ContactInfo currentContact = ContactManagementContext.GetCurrentContact();

            // For the tracking consent, lowers the cookie level to the site's default in order to disable tracking
            if (consent.ConsentName == "SampleTrackingConsent")
            {
                currentCookieLevelProvider.SetCurrentCookieLevel(currentCookieLevelProvider.GetDefaultCookieLevel());
            }

            // Revokes the consent agreement
            consentAgreementService.Revoke(currentContact, consent);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #8
0
        public IViewComponentResult Invoke()
        {
            var consent = consentInfoProvider.Get(TrackingConsentGenerator.CONSENT_NAME);

            if (consent != null)
            {
                var consentModel = new ConsentViewModel
                {
                    ConsentShortText = consent.GetConsentText(System.Threading.Thread.CurrentThread.CurrentUICulture.Name).ShortText
                };

                var contact = CMS.ContactManagement.ContactManagementContext.CurrentContact;
                if ((contact != null) && consentAgreementService.IsAgreed(contact, consent))
                {
                    consentModel.IsConsentAgreed = true;
                }

                return(View("~/Components/ViewComponents/TrackingConsent/_TrackingConsent.cshtml", consentModel));
            }

            return(Content(string.Empty));
        }