From 012a57956a61273cf9ef8e27c5e4b00ad4cbb178 Mon Sep 17 00:00:00 2001 From: Alex <$(pass /github/email)> Date: Wed, 19 Feb 2025 12:06:51 +0100 Subject: [PATCH] frontend: fix refreshCookie --- frontend/src/lib/utils/helpers.js | 39 +++---------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/frontend/src/lib/utils/helpers.js b/frontend/src/lib/utils/helpers.js index f4b82b8..26fd673 100644 --- a/frontend/src/lib/utils/helpers.js +++ b/frontend/src/lib/utils/helpers.js @@ -184,13 +184,13 @@ export function formatError(obj) { /** * * @param {string | null} newToken - The new token for the cookie to set - * @param {import('@sveltejs/kit').RequestEvent } event - The event object + * @param {import('@sveltejs/kit').Cookies } cookies - The event object */ -export function refreshCookie(newToken, event) { +export function refreshCookie(newToken, cookies) { if (newToken) { const match = newToken.match(/jwt=([^;]+)/); if (match) { - event.cookies.set('jwt', match[1], { + cookies.set('jwt', match[1], { path: '/', httpOnly: true, secure: process.env.NODE_ENV === 'production', // Secure in production @@ -200,36 +200,3 @@ export function refreshCookie(newToken, event) { } } } - -/** - * Creates a debounced version of an input event handler. - * - * @param {HTMLElement} element - The HTML element to attach the debounced event to. - * @param {number} duration - The delay in milliseconds before the event is triggered after the last input. - * @returns {Object} - An object with a `destroy` method to clean up the event listener. - * - * @example - * - */ -export function debounce(element, duration) { - /** @type{NodeJS.Timeout} */ - let timer; - - /** - * - * @param {CustomEventInit} e - */ - function input(e) { - clearTimeout(timer); - timer = setTimeout(() => { - element.dispatchEvent(new CustomEvent('debouncedinput', e)); - }, duration); - } - - element.addEventListener('input', input); - return { - destroy() { - element.removeEventListener('input', input); - } - }; -}