Skip to content

Commit

Permalink
feat(nuxt-base): remove init_oauth stale cookie deletion and move to …
Browse files Browse the repository at this point in the history
…app-extension-auth (#66)
  • Loading branch information
BibiSebi authored Jul 3, 2024
1 parent 1545c8f commit 05504c6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions space-plugins/nuxt-base/server/middleware/02.auth.global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ export default defineEventHandler(async (event) => {
return;
}

// Delete cookie and initiated OAuth flow
// if the user hasn't been authenticated yet.
// If the user hasn't been authenticated yet.
// (Storyfront attaches this query parameter in that case)
if (getQuery(event)['init_oauth'] === 'true') {
setCookie(event, AUTH_COOKIE_NAME, '', {
httpOnly: true,
secure: true,
sameSite: 'none',
});
return await sendRedirect(event, appConfig.auth.initOauthFlowUrl, 302);
const queryParams = getQuery(event);
if (queryParams['init_oauth'] === 'true') {
return await sendRedirect(
event,
`${appConfig.auth.initOauthFlowUrl}?init_oauth=true`,
302,
);
}

const appSession = await getAppSession(event);
Expand Down

0 comments on commit 05504c6

Please sign in to comment.