2023-07-31 12:18:17 +00:00
|
|
|
-- Verify camper:campsite_type on pg
|
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
select campsite_type_id
|
|
|
|
, company_id
|
|
|
|
, slug
|
|
|
|
, name
|
|
|
|
, description
|
|
|
|
, active
|
|
|
|
from camper.campsite_type
|
|
|
|
where false;
|
|
|
|
|
|
|
|
select 1 / count(*) from pg_class where oid = 'camper.campsite_type'::regclass and relrowsecurity;
|
Move the user role down to company_user relation
I was starting to add the public page for campsite types, creating more
granular row-level security policies for select, insert, update, and
delete, because now the guest users needed to SELECT them and they have
no related company to filter the rows with. Suddenly, i realized that
the role was wrong in the user relation: a user can be an admin to one
company, and employee to another, and guess to yet another company;
the role should be in the company_user relation instead.
That means that to know the role to set to, the user alone is not enough
and have to know the company as well. Had to change all the
cookie-related function to accept also the company’s host name, as this
is the information that the Go application has.
2023-08-08 00:22:16 +00:00
|
|
|
select 1 / count(*) from pg_policy where polname = 'guest_ok' and polrelid = 'camper.campsite_type'::regclass;
|
|
|
|
select 1 / count(*) from pg_policy where polname = 'insert_to_company' and polrelid = 'camper.campsite_type'::regclass;
|
|
|
|
select 1 / count(*) from pg_policy where polname = 'update_company' and polrelid = 'camper.campsite_type'::regclass;
|
|
|
|
select 1 / count(*) from pg_policy where polname = 'delete_from_company' and polrelid = 'camper.campsite_type'::regclass;
|
2023-07-31 12:18:17 +00:00
|
|
|
|
|
|
|
rollback;
|