27 lines
860 B
Plaintext
27 lines
860 B
Plaintext
@{
|
|
var nonce = _accessor.HttpContext?.Items["csp-nonce"] as string;
|
|
}
|
|
@using DigitalData.Core.DTO;
|
|
@using Microsoft.AspNetCore.Http.Features
|
|
@using Newtonsoft.Json.Serialization;
|
|
@using Newtonsoft.Json;
|
|
@inject CookieConsentSettings _cookieSettings
|
|
@{
|
|
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
|
|
var showBanner = !consentFeature?.CanTrack ?? false;
|
|
var cookieString = consentFeature?.CreateConsentCookie();
|
|
}
|
|
@if (showBanner)
|
|
{
|
|
<script nonce="@nonce">
|
|
@{
|
|
var serializerSettings = new JsonSerializerSettings
|
|
{
|
|
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
|
};
|
|
string serializedProps = JsonConvert.SerializeObject(_cookieSettings, serializerSettings);
|
|
}
|
|
var props = @Html.Raw(serializedProps);
|
|
var cookieSettings = new BootstrapCookieConsentSettings(props)
|
|
</script>
|
|
} |