Skip to content

Commit

Permalink
testing github auth
Browse files Browse the repository at this point in the history
  • Loading branch information
psiddharthdesign committed Jul 22, 2024
1 parent c62d84e commit 63c4adf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function UserOnboardingFlow({
getInitialFlowState(flowStates, onboardingStatus)
);

const { replace } = useRouter();
const router = useRouter();

const nextStep = useCallback(() => {
const currentIndex = flowStates.indexOf(currentStep);
Expand All @@ -48,9 +48,9 @@ export function UserOnboardingFlow({
console.log('currentStep is COMPLETE', currentStep);
console.log('onboardingStatus : ', onboardingStatus);
console.log('now redirecting to /dashboard');
replace("/dashboard");
router.push("/dashboard");
}
}, [currentStep, replace]);
}, [currentStep, router, onboardingStatus]);

const cardVariants = {
hidden: { opacity: 0, y: 50 },
Expand Down
4 changes: 4 additions & 0 deletions src/data/user/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ export async function setOnboardingStatus(): Promise<
},
});

console.log('updateAuthUser : ', updateAuthUser);

if (updateAuthUser.error) {
console.log('Failed to update onboarding status. reason : ', updateAuthUser.error);
return {
status: "error",
message: updateAuthUser.error.message,
Expand All @@ -302,6 +305,7 @@ export async function setOnboardingStatus(): Promise<
const refreshSessionResponse = await supabaseClient.auth.refreshSession();

if (refreshSessionResponse.error) {
console.log('Failed to refresh session. reason : ', refreshSessionResponse.error);
return {
status: "error",
message: refreshSessionResponse.error.message,
Expand Down
9 changes: 9 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,17 @@ export async function middleware(req: NextRequest) {
const supabase = createMiddlewareClient<Database>({ req, res });
const sessionResponse = await supabase.auth.getSession();
const maybeUser = sessionResponse?.data.session?.user;
console.log(
'Checking if user should be onboarded:',
req.nextUrl.pathname,
maybeUser,
);
if (shouldOnboardUser(req.nextUrl.pathname, maybeUser)) {
console.log('redirecting to onboarding');
console.log(
'shouldOnboardUser result:',
shouldOnboardUser(req.nextUrl.pathname, maybeUser),
);
return NextResponse.redirect(toSiteURL('/onboarding'));
}
if (!isUnprotectedPage(req.nextUrl.pathname) && maybeUser) {
Expand Down

0 comments on commit 63c4adf

Please sign in to comment.