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

View File

@ -9,6 +9,9 @@ function isAnalyticsOn(ctx) {
// Rely on the client // Rely on the client
cookies = document.cookie; cookies = document.cookie;
} }
if(!cookies) return true;
let processed = {} let processed = {}
cookies.split(';').forEach((e) => { cookies.split(';').forEach((e) => {
let val = e.trim().split('='); let val = e.trim().split('=');
@ -34,7 +37,6 @@ export default async function (ctx, inject) {
if (!enabled) { if (!enabled) {
console.log("Analytics are not enabled.")
return; return;
} }

View File

@ -1,7 +1,7 @@
import Vue from 'vue'; import Vue from 'vue';
function isPersonalizedAdsOn(ctx) { function isPersonalizedAdsOn(ctx) {
let cookies = null let cookies = []
if (ctx.req != null) { if (ctx.req != null) {
//Server side rendering //Server side rendering
cookies = ctx.req.headers.cookie; cookies = ctx.req.headers.cookie;
@ -9,6 +9,9 @@ function isPersonalizedAdsOn(ctx) {
// Rely on the client // Rely on the client
cookies = document.cookie; cookies = document.cookie;
} }
if(!cookies) return true;
let processed = {} let processed = {}
cookies.split(';').forEach((e) => { cookies.split(';').forEach((e) => {
let val = e.trim().split('=') let val = e.trim().split('=')

View File

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

View File

@ -47,20 +47,25 @@
import scopes from '@/privacy-toggles' import scopes from '@/privacy-toggles'
export default { export default {
name: 'Privacy', name: 'Privacy',
data: () => { fetch() {
const settings = scopes.settings Object.keys(scopes.settings).forEach((key) => {
return { scopes.settings[key].value = scopes.settings[key].default
scopes: settings, })
}
},
mounted() {
this.$store.dispatch('consent/loadFromCookies', this.$cookies) this.$store.dispatch('consent/loadFromCookies', this.$cookies)
// Load the allowed scopes from the store // Load the allowed scopes from the store
this.$store.state.consent.scopes_allowed.forEach((scope) => { this.$store.state.consent.scopes_allowed.forEach((scope) => {
if (this.scopes[scope] != null) if (this.scopes[scope] != null)
this.$set(this.scopes[scope], 'value', true) this.$set(this.scopes[scope], 'value', true)
}) })
}, },
data: () => {
const settings = scopes.settings
return {
scopes: settings,
}
},
options: { options: {
auth: false, 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. 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 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.`, based on the information stored in this cookie.`,
default: false, default: true,
}, },
analytics: { analytics: {
title: 'Analytics', title: 'Analytics',

View File

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