Skip to content

Commit

Permalink
fix(auth)!: silently ignore auth to support unauthenticated pages
Browse files Browse the repository at this point in the history
  • Loading branch information
amandesai01 committed Sep 9, 2024
1 parent 6f61c19 commit a9d3690
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions app/plugins/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ export default defineNuxtPlugin(async () => {
try {
const res = await useAsyncData<Session>('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);
}
});

0 comments on commit a9d3690

Please sign in to comment.