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:
@@ -0,0 +1,37 @@
|
||||
create type "medreport"."application_role" as enum ('user', 'doctor', 'super_admin');
|
||||
|
||||
ALTER TABLE medreport.accounts
|
||||
ADD COLUMN "application_role" medreport.application_role NOT NULL DEFAULT 'user';
|
||||
|
||||
CREATE OR REPLACE FUNCTION medreport.is_doctor()
|
||||
RETURNS BOOLEAN
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN medreport.is_aal2() AND (EXISTS (
|
||||
SELECT 1
|
||||
FROM medreport.accounts
|
||||
WHERE primary_owner_user_id = auth.uid()
|
||||
AND application_role = 'doctor'
|
||||
));
|
||||
END;
|
||||
$$;
|
||||
grant execute on function medreport.is_doctor() to authenticated;
|
||||
|
||||
|
||||
CREATE OR REPLACE FUNCTION medreport.is_super_admin()
|
||||
RETURNS BOOLEAN
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN medreport.is_aal2() AND (EXISTS (
|
||||
SELECT 1
|
||||
FROM medreport.accounts
|
||||
WHERE primary_owner_user_id = auth.uid()
|
||||
AND application_role = 'super_admin'
|
||||
));
|
||||
END;
|
||||
$$;
|
||||
grant execute on function medreport.is_super_admin() to authenticated;
|
||||
@@ -1,2 +0,0 @@
|
||||
-- Update your user role to Super Admin
|
||||
update auth.users set raw_app_meta_data='{"provider": "email", "providers": ["email"], "role": "super-admin" }' where email='test2@test.ee';
|
||||
Reference in New Issue
Block a user