Commit 1ab64fb 1 parent fef0536 commit 1ab64fb Copy full SHA for 1ab64fb
File tree 5 files changed +25
-2
lines changed
5 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1
1
SUPABASE_AUTH_DISCORD_CLIENT_ID = " 1234567890"
2
2
SUPABASE_AUTH_DISCORD_SECRET = " some_random_key"
3
3
NEXT_PUBLIC_SUPABASE_ANON_KEY = " some_random_key, found by running supabase start or supabase status"
4
+ SUPABASE_SERVICE_KEY = " some_random_key, found by running supabase start or supabase status"
4
5
JWT_SECRET = " super-secret-jwt-token-with-at-least-32-characters-long"
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ Copy the following output values to your environment file:
77
77
` anon key ` to ` NEXT_PUBLIC_SUPABASE_ANON_KEY `
78
78
` API URL ` to ` NEXT_PUBLIC_SUPABASE_URL `
79
79
` JWT secret ` to ` JWT_SECRET `
80
+ ` service_role key ` to ` SUPABASE_SERVICE_KEY `
80
81
81
82
To stop running supabase, type ` supabase stop ` into your terminal.
82
83
Original file line number Diff line number Diff line change 1
1
import { createClient } from "@/lib/database/server" ;
2
- import { createServerClient } from "@supabase/ssr " ;
2
+ import { createServiceClient } from "@/lib/database/service " ;
3
3
import { NextResponse } from "next/server" ;
4
4
5
5
interface DiscordGuildMemberResponse {
@@ -58,6 +58,9 @@ export async function GET(request: Request) {
58
58
) . then ( ( res ) => res . json ( ) ) ;
59
59
60
60
if ( ! servers || servers ?. code ) {
61
+ const serviceClient = createServiceClient ( ) ;
62
+
63
+ await serviceClient . auth . admin . deleteUser ( user . id ) ;
61
64
await supabase . auth . signOut ( ) ;
62
65
return NextResponse . redirect ( `${ origin } /403` ) ;
63
66
}
Original file line number Diff line number Diff line change 1
- import { createServerClient , type CookieOptions } from "@supabase/ssr" ;
1
+ import { createServerClient } from "@supabase/ssr" ;
2
2
import { cookies } from "next/headers" ;
3
3
4
4
export function createClient ( ) {
Original file line number Diff line number Diff line change
1
+ import { createClient } from "@supabase/supabase-js" ;
2
+
3
+ /**
4
+ * SHOULD ONLY EVER BE USED ON SERVER
5
+ */
6
+ export function createServiceClient ( ) {
7
+ return createClient (
8
+ process . env . NEXT_PUBLIC_SUPABASE_URL ! ,
9
+ process . env . SUPABASE_SERVICE_KEY ! ,
10
+ {
11
+ auth : {
12
+ persistSession : false ,
13
+ autoRefreshToken : false ,
14
+ detectSessionInUrl : false ,
15
+ } ,
16
+ }
17
+ ) ;
18
+ }
You can’t perform that action at this time.
0 commit comments