Skip to content

Commit

Permalink
Merge pull request #71 from diggerhq/feat/fix-github-callback-session
Browse files Browse the repository at this point in the history
fix github callback
  • Loading branch information
ZIJ authored Oct 31, 2024
2 parents 324451a + 47e0cb9 commit 6c10b6a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/app/api/github-callback/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createSupabaseUserRouteHandlerClient } from '@/supabase-clients/user/createSupabaseUserRouteHandlerClient';
import { toSiteURL } from '@/utils/helpers';
import { getSession } from '@/utils/server/verifySession';
import { NextRequest, NextResponse } from 'next/server';

// Use the environment variable for the callback URL
Expand Down Expand Up @@ -59,10 +60,17 @@ async function getOrganizationId(): Promise<string> {
console.error('Failed to get current user', error);
throw error;
}

const session = await getSession();
const userId = session.data.session?.user.id;
if (userId === undefined) {
console.log();
throw Error('could not verify session');
}
const { data: orgs, error: errOrg } = await supabase
.from('organization_members')
.select('*')
.eq('member_id', user.id);
.eq('member_id', userId);

if (errOrg || !orgs[0]) {
console.error('Failed to get org');
Expand Down

0 comments on commit 6c10b6a

Please sign in to comment.