victorwhiskey
05/16/2022, 12:15 PMNeedle
05/16/2022, 12:15 PMvictorwhiskey
05/16/2022, 12:26 PMvictorwhiskey
05/16/2022, 12:26 PMvictorwhiskey
05/16/2022, 12:33 PMvictorwhiskey
05/16/2022, 12:33 PMgaryaustin
05/16/2022, 1:23 PMNeedle
05/16/2022, 1:23 PMgaryaustin
05/16/2022, 1:28 PMScott P
05/16/2022, 2:16 PMsql
(id === uid() OR is_admin)
This requires that your profile table has an id
column which is set to the corresponding UID record in the auth.users
table, and an is_admin
boolean column
Conditions output if we look at it on an individual row basis:
- ID matches, user is admin: Can access all rows
- ID matches, user is not admin: Can access this row
- ID doesn't match, user is admin: Can access all rows
- ID doesn't match, user is not admin: Can not access this rowvictorwhiskey
05/16/2022, 11:08 PMvictorwhiskey
05/16/2022, 11:53 PMvictorwhiskey
05/16/2022, 11:57 PMvictorwhiskey
05/16/2022, 11:58 PMvictorwhiskey
05/17/2022, 1:27 AMburggraf
05/17/2022, 1:28 AMburggraf
05/17/2022, 1:28 AMburggraf
05/17/2022, 1:28 AMburggraf
05/17/2022, 1:28 AMvictorwhiskey
05/17/2022, 1:29 AMburggraf
05/17/2022, 1:29 AMvictorwhiskey
05/17/2022, 1:29 AMburggraf
05/17/2022, 1:30 AMburggraf
05/17/2022, 1:30 AMvictorwhiskey
05/17/2022, 1:31 AMburggraf
05/17/2022, 1:31 AMCREATE OR REPLACE FUNCTION auth.get_claims() RETURNS "jsonb"
LANGUAGE "sql" STABLE
AS $$
select
coalesce(nullif(current_setting('request.jwt.claims', true), '')::jsonb -> 'app_metadata', '{}'::jsonb)::jsonb
$$;
burggraf
05/17/2022, 1:31 AMburggraf
05/17/2022, 1:32 AM