//EndDocSection:Constructor //DocSection:DisplayConsent public ActionResult DisplayConsent() { // Gets the related tracking consent // Fill in the code name of the appropriate consent object in Kentico ConsentInfo consent = ConsentInfoProvider.GetConsentInfo("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)); }
private void UseDefaultCookieLevelWhenConsentIsNotAgreed() { var consent = ConsentInfoProvider.GetConsentInfo(TrackingConsent); var contact = ContactManagementContext.CurrentContact; if (consent != null && contact != null) { if (!Service.Resolve <IConsentAgreementService>().IsAgreed(contact, consent)) { cookieLevelProvider.SetCurrentCookieLevel(cookieLevelProvider.GetDefaultCookieLevel()); } } }
public ActionResult Revoke(int consentId) { // Gets the related consent object ConsentInfo consent = ConsentInfoProvider.GetConsentInfo(consentId); // Gets the current visitor's contact ContactInfo currentContact = contactTrackingService.GetCurrentContactAsync(User.Identity.Name).Result; // 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("Index")); }
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))); }
public ActionResult Revoke(string consentName) { var consentToRevoke = ConsentInfoProvider.GetConsentInfo(consentName); if (consentToRevoke != null && CurrentContact != null) { mConsentAgreementService.Revoke(CurrentContact, consentToRevoke); if (consentName == TrackingConsentGenerator.CONSENT_NAME) { mCookieLevelProvider.SetCurrentCookieLevel(mCookieLevelProvider.GetDefaultCookieLevel()); ExecuteRevokeTrackingConsentTask(mSiteService.CurrentSite, CurrentContact); } TempData[SUCCESS_RESULT] = true; } else { TempData[ERROR_RESULT] = true; } return(RedirectToAction("Index")); }