campingmontagut/verify/user_profile.sql
jordi fita mas 5d0861824a Add authentication relations, views, and functions for PostgreSQL
Most of them are exactly the same as we use for Numerus, but with the
main application schema changed to camper.

Closes #1
2023-07-22 01:59:12 +02:00

46 lines
1.4 KiB
PL/PgSQL

-- Verify camper:user_profile on pg
begin;
select user_id
, email
, name
, role
, lang_tag
, csrf_token
from camper.user_profile
where false;
select has_function_privilege('camper.update_user_profile()', 'execute');
select 1 / count(*)
from pg_trigger
where not tgisinternal
and tgname = 'update_user_profile'
and tgrelid = 'camper.user_profile'::regclass
and tgtype = b'01010001'::int;
-- │││││││
-- ││││││└─> row
-- │││││└──> before
-- ││││└───> insert
-- │││└────> delete
-- ││└─────> update
-- │└──────> truncate
-- └───────> instead
select 1 / count(*)
from pg_trigger
where not tgisinternal
and tgname = 'encrypt_password'
and tgrelid = 'auth.user'::regclass
and tgtype = b'00010111'::int;
-- │││││││
-- ││││││└─> row
-- │││││└──> before
-- ││││└───> insert
-- │││└────> delete
-- ││└─────> update
-- │└──────> truncate
-- └───────> instead
rollback;