The update implemented a redirect functionality in the multi-factor authentication flow for a better user experience. It also involved a refactoring of some parts of the code, substituting direct routing paths with path configs for easier future modifications. Import statements were adjusted for better code organization and readability.
20 lines
411 B
TypeScript
20 lines
411 B
TypeScript
import { SupabaseClient } from '@supabase/supabase-js';
|
|
|
|
import { Database } from '@kit/supabase/database';
|
|
|
|
export async function isSuperAdmin(client: SupabaseClient<Database>) {
|
|
const { data, error } = await client.auth.getUser();
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
if (!data.user) {
|
|
return false;
|
|
}
|
|
|
|
const appMetadata = data.user.app_metadata;
|
|
|
|
return appMetadata?.role === 'super-admin';
|
|
}
|