mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-19 22:14:06 +01:00
feat: add delete user function for test
This commit is contained in:
parent
0c719a093d
commit
0523f6d712
26
tests/helpers/deleteUser.ts
Normal file
26
tests/helpers/deleteUser.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { createClient } from "@supabase/supabase-js";
|
||||||
|
|
||||||
|
const supabase_url = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||||
|
const supabase_anon_key = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
||||||
|
|
||||||
|
if (!supabase_url) {
|
||||||
|
throw "Supabase Url is undefine";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!supabase_anon_key) {
|
||||||
|
throw "Supabase Anon Key is undefine";
|
||||||
|
}
|
||||||
|
|
||||||
|
const supabase = createClient(supabase_url, supabase_anon_key);
|
||||||
|
|
||||||
|
export async function deleteUser(userId: string) {
|
||||||
|
try {
|
||||||
|
const { data, error } = await supabase.auth.admin.deleteUser(userId);
|
||||||
|
if (error) throw error;
|
||||||
|
console.log(`User ${userId} deleted successfully.`);
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error deleting user ${userId}:`, error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user