Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(space-nuxt-base): remove init_oauth stale cookie deletion and move to app-extension-auth #66

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think initOauthFlowUrl will likely already include ?, but just in case, could we do this a bit differently like

const url = new URL(appConfig.auth.initOauthFlowUrl);
// add `init_oauth` to `url`

302,
);
}

const appSession = await getAppSession(event);
Expand Down
Loading