From e38f3ed100e8c8ff9ac7fe06b1abe360d28b58c0 Mon Sep 17 00:00:00 2001 From: KwikKill Date: Fri, 1 Dec 2023 13:33:45 +0100 Subject: [PATCH] Fix get csrf method --- src/stores/user.store.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/stores/user.store.ts b/src/stores/user.store.ts index e3f8616..f7445d6 100755 --- a/src/stores/user.store.ts +++ b/src/stores/user.store.ts @@ -33,15 +33,13 @@ export const useUserStore = defineStore('user', () => { */ async function get_csrf() { await axios.get('/user/get-csrf/'); - const cookies: { name: string; value: string }[] = []; - document.cookie.split(';').forEach((cookie) => { - cookies.push({ - name: cookie.split('=')[0], - value: cookie.split('=')[1], - }); + let cookie = ''; + document.cookie.split(';').forEach((cookie_value) => { + if (cookie_value.split('=')[0].trim() === 'csrftoken') { + cookie = cookie_value.split('=')[1].trim(); + } }); - const token = cookies.find((cookie) => cookie.name === 'csrftoken'); - csrf.value = token ? token.value : ''; + csrf.value = cookie; } /* API Call to verify an email address (an email with a URL made with the name