Refactor authentication flow and improve code organization
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.
This commit is contained in:
19
packages/features/admin/src/lib/is-super-admin.ts
Normal file
19
packages/features/admin/src/lib/is-super-admin.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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';
|
||||
}
|
||||
Reference in New Issue
Block a user