Skip to content

Commit

Permalink
fix(web): onboading existing session redirect issue
Browse files Browse the repository at this point in the history
  • Loading branch information
cstrnt committed Sep 3, 2023
1 parent 084a612 commit adc8545
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/web/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default withAuth(
// redirect to /welcome if user has not completed onboarding
if (
pathName.startsWith("/projects") &&
!req.nextauth.token?.user.hasCompletedOnboarding
req.nextauth.token?.user &&
// required check since old sessions don't have this field
"hasCompletedOnboarding" in req.nextauth.token.user &&
req.nextauth.token.user.hasCompletedOnboarding === false
) {
const newUrl = new URL(req.nextUrl);
newUrl.pathname = "/welcome";
Expand Down

1 comment on commit adc8545

@vercel
Copy link

@vercel vercel bot commented on adc8545 Sep 3, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.