Fix issues with privacy settings

This commit is contained in:
Jai A 2021-04-10 21:54:16 -07:00
parent 03b2d02742
commit 7d3ad5a639
No known key found for this signature in database
GPG Key ID: FA67B378D4514667
7 changed files with 40 additions and 23 deletions

View File

@ -13,8 +13,8 @@
button below:
</span>
<div class="actions">
<button class="btn button" @click="hide">Accept all</button>
<button class="btn brand-button" @click="review">Review</button>
<button class="btn button" @click="review">Review</button>
<button class="btn brand-button" @click="hide">Accept all</button>
</div>
</div>
</div>
@ -24,12 +24,7 @@
<script>
export default {
name: 'CookieConsent',
data() {
return {
shown: false,
}
},
mounted() {
fetch() {
// Get informations in the store
this.$store.dispatch('consent/loadFromCookies', this.$cookies)
if (
@ -39,12 +34,20 @@ export default {
this.shown = true
}
},
data() {
return {
shown: false,
}
},
methods: {
hide() {
this.shown = false
this.$store.commit('consent/set_consent', true)
this.$store.commit('consent/add_scope', true)
this.$store.commit('consent/remove_scope', true)
this.$store.dispatch('consent/save', this.$cookies)
},
review() {
this.hide()
this.shown = false
this.$router.push('/dashboard/privacy')
},
},

View File

@ -9,6 +9,9 @@ function isAnalyticsOn(ctx) {
// Rely on the client
cookies = document.cookie;
}
if(!cookies) return true;
let processed = {}
cookies.split(';').forEach((e) => {
let val = e.trim().split('=');
@ -27,14 +30,13 @@ export default async function (ctx, inject) {
const tag = config.tracking_code ?? '<%= options.tracking_code %>';
const enabled = config.enabled ?? <%= options.enabled || false %>;
// Check if the parameters are not changed by runtime config:
const UNAMI_LIB_TAG_ID = '<%= options.UNAMI_LIB_TAG_ID %>';
if (!enabled) {
console.log("Analytics are not enabled.")
return;
}

View File

@ -1,7 +1,7 @@
import Vue from 'vue';
function isPersonalizedAdsOn(ctx) {
let cookies = null
let cookies = []
if (ctx.req != null) {
//Server side rendering
cookies = ctx.req.headers.cookie;
@ -9,6 +9,9 @@ function isPersonalizedAdsOn(ctx) {
// Rely on the client
cookies = document.cookie;
}
if(!cookies) return true;
let processed = {}
cookies.split(';').forEach((e) => {
let val = e.trim().split('=')
@ -102,7 +105,7 @@ export default async function (ctx, inject) {
};
injectScript(gptInitScript);
const component = require('./component.js');
Vue.component('<%= options.componentName %>', component.default || component);

View File

@ -29,6 +29,10 @@
<SettingsIcon />
Settings
</nuxt-link>
<nuxt-link :to="'/dashboard/privacy'" class="tab last">
<SettingsIcon />
Privacy Settings
</nuxt-link>
</div>
<div v-else class="card page-nav">
<a :href="authUrl" class="tab last">

View File

@ -47,20 +47,25 @@
import scopes from '@/privacy-toggles'
export default {
name: 'Privacy',
data: () => {
const settings = scopes.settings
return {
scopes: settings,
}
},
mounted() {
fetch() {
Object.keys(scopes.settings).forEach((key) => {
scopes.settings[key].value = scopes.settings[key].default
})
this.$store.dispatch('consent/loadFromCookies', this.$cookies)
// Load the allowed scopes from the store
this.$store.state.consent.scopes_allowed.forEach((scope) => {
if (this.scopes[scope] != null)
this.$set(this.scopes[scope], 'value', true)
})
},
data: () => {
const settings = scopes.settings
return {
scopes: settings,
}
},
options: {
auth: false,
},

View File

@ -5,7 +5,7 @@ export default {
description: `Marketing/target cookies are usually used to show you advertisements that meet your interests.
When you visit another website, your browser's cookie is recognized and selected ads are displayed to you
based on the information stored in this cookie.`,
default: false,
default: true,
},
analytics: {
title: 'Analytics',

View File

@ -36,7 +36,7 @@ export const actions = {
}
state.commit('set_consent', $cookies.get('modrinth-consent') === true)
const scopes = $cookies.get('modrinth-scopes')
if (scopes == null) return
if (!scopes) return
scopes.split(',').forEach((elem) => {
state.commit('add_scope', elem)
})