diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 91b5895..1be1130 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,8 +1,8 @@ import { directus } from '$lib/directus' +import { verifyCookie } from '$lib/utils/cookies' import { log } from '@arturoguzman/art-ui' import { type Handle } from '@sveltejs/kit' -const roles = ['carer', 'healthcare-professional'] export const handle: Handle = async ({ event, resolve }) => { // const id = getId() // console.time(`id: ${id}`) @@ -13,7 +13,7 @@ export const handle: Handle = async ({ event, resolve }) => { role: event.cookies.get('etips-role') ?? 'public' } const role = event.cookies.get('etips-role') - if (role && !roles.includes(role)) { + if (!verifyCookie(role, ['carer', 'healthcare-professional'])) { event.cookies.delete('etips-disclaimer-consent', { path: '/' }) event.cookies.delete('etips-role', { path: '/' }) event.cookies.delete('etips-side', { path: '/' }) diff --git a/src/lib/ui/form/access_form.svelte b/src/lib/ui/form/access_form.svelte index 57faf34..4e78ee2 100644 --- a/src/lib/ui/form/access_form.svelte +++ b/src/lib/ui/form/access_form.svelte @@ -1,5 +1,5 @@