-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenable_admin_permissions.sql
More file actions
29 lines (24 loc) · 1.16 KB
/
Copy pathenable_admin_permissions.sql
File metadata and controls
29 lines (24 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- Enable Admin Permissions
-- Run this in your Supabase SQL Editor to allow Admins to Edit and Delete users.
-- 1. Policies for Profiles Table
-- Allow admins to update any user's profile (Users can only update their own)
create policy "Admins can update any profile" on profiles for update using (
exists (select 1 from roles where user_id = auth.uid() and role = 'admin')
);
-- Allow admins to delete any user's profile
create policy "Admins can delete any profile" on profiles for delete using (
exists (select 1 from roles where user_id = auth.uid() and role = 'admin')
);
-- 2. Policies for Roles Table
-- Allow admins to assign roles (insert)
create policy "Admins can insert roles" on roles for insert with check (
exists (select 1 from roles where user_id = auth.uid() and role = 'admin')
);
-- Allow admins to change roles (update)
create policy "Admins can update roles" on roles for update using (
exists (select 1 from roles where user_id = auth.uid() and role = 'admin')
);
-- Allow admins to remove roles (delete)
create policy "Admins can delete roles" on roles for delete using (
exists (select 1 from roles where user_id = auth.uid() and role = 'admin')
);