Skip to content

Commit

Permalink
fix callback
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes committed Oct 31, 2024
1 parent 63d7bb2 commit 47e0cb9
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 47e0cb9

Please sign in to comment.