From a9d3690f774f5a601aa8e3554359d27df879498a Mon Sep 17 00:00:00 2001 From: amandesai01 Date: Mon, 9 Sep 2024 20:47:00 +0530 Subject: [PATCH] fix(auth)!: silently ignore auth to support unauthenticated pages --- app/plugins/auth.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/plugins/auth.ts b/app/plugins/auth.ts index 2b0bb34..8cdc24a 100644 --- a/app/plugins/auth.ts +++ b/app/plugins/auth.ts @@ -6,15 +6,8 @@ export default defineNuxtPlugin(async () => { try { const res = await useAsyncData('oauth-sess-fetch', () => requestFetch('/api/userinfo')); const fetchedSession = res.data.value; - if (!fetchedSession) { - throw new Error('Empty session received'); - } - session.value = fetchedSession; + session.value = fetchedSession as Session; // it's ok if data not present. } catch (e) { - console.error('Error fetching user.', e); - throw createError({ - statusCode: 500, - statusMessage: 'Unable to setup session. Try again later', - }); + console.error('Error while fetching session', e); } });