MED-109: add doctor role and basic view (#45)
* MED-109: add doctor role and basic view * add role to accounts * remove old super admin and doctor sql
This commit is contained in:
24
packages/features/doctor/src/lib/server/utils/is-doctor.ts
Normal file
24
packages/features/doctor/src/lib/server/utils/is-doctor.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { SupabaseClient } from '@supabase/supabase-js';
|
||||
|
||||
import { Database } from '@kit/supabase/database';
|
||||
|
||||
/**
|
||||
* @name isDoctor
|
||||
* @description Check if the current user is a doctor.
|
||||
* @param client
|
||||
*/
|
||||
export async function isDoctor(client: SupabaseClient<Database>) {
|
||||
try {
|
||||
const { data, error } = await client
|
||||
.schema('medreport')
|
||||
.rpc('is_doctor');
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user