Compare commits
2 commits
main
...
feature/#1
Author | SHA1 | Date | |
---|---|---|---|
d2eaf3bd98 | |||
6441716a00 |
|
@ -90,6 +90,43 @@ $$ language plpgsql strict
|
||||||
security definer;
|
security definer;
|
||||||
grant execute on function candymat_data.authenticate(text, text) to candymat_anonymous, candymat_person;
|
grant execute on function candymat_data.authenticate(text, text) to candymat_anonymous, candymat_person;
|
||||||
|
|
||||||
|
-- Change password
|
||||||
|
drop function if exists candymat_data.change_password;
|
||||||
|
create function candymat_data.change_password(
|
||||||
|
email text,
|
||||||
|
old_password text,
|
||||||
|
new_password text
|
||||||
|
) returns candymat_data.jwt_token as
|
||||||
|
$$
|
||||||
|
declare
|
||||||
|
account candymat_data_privat.person_account;
|
||||||
|
declare person candymat_data.person;
|
||||||
|
begin
|
||||||
|
select a.*
|
||||||
|
into account
|
||||||
|
from candymat_data_privat.person_account as a
|
||||||
|
where a.email = $1;
|
||||||
|
|
||||||
|
select p.*
|
||||||
|
into person
|
||||||
|
from candymat_data.person as p
|
||||||
|
where p.row_id = account.person_row_id;
|
||||||
|
|
||||||
|
if account.password_hash = crypt(old_password, account.password_hash) then
|
||||||
|
|
||||||
|
select *
|
||||||
|
from candymat_data.person
|
||||||
|
where row_id = nullif(current_setting('jwt.claims.person_row_id', true), '')::integer
|
||||||
|
|
||||||
|
return (person.role, account.person_row_id,
|
||||||
|
extract(epoch from (now() + interval '2 days')))::candymat_data.jwt_token;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
end if;
|
||||||
|
end;
|
||||||
|
$$ language plpgsql strict
|
||||||
|
security definer;
|
||||||
|
grant execute on function candymat_data.change_role(integer, candymat_data.role) to candymat_editor;
|
||||||
|
|
||||||
-- Change role: Changes role for a given user. Only editors are allowed to use it.
|
-- Change role: Changes role for a given user. Only editors are allowed to use it.
|
||||||
drop function if exists candymat_data.change_role;
|
drop function if exists candymat_data.change_role;
|
||||||
|
@ -109,5 +146,6 @@ begin
|
||||||
|
|
||||||
return person;
|
return person;
|
||||||
end;
|
end;
|
||||||
$$ language plpgsql strict security definer;
|
$$ language plpgsql strict
|
||||||
|
security definer;
|
||||||
grant execute on function candymat_data.change_role(integer, candymat_data.role) to candymat_editor;
|
grant execute on function candymat_data.change_role(integer, candymat_data.role) to candymat_editor;
|
|
@ -28,10 +28,10 @@ services:
|
||||||
image: candymat-postgres:11.5
|
image: candymat-postgres:11.5
|
||||||
build:
|
build:
|
||||||
dockerfile: ./Dockerfile
|
dockerfile: ./Dockerfile
|
||||||
context: ./backend/
|
context: ./backend/db
|
||||||
environment:
|
environment:
|
||||||
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
|
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
|
||||||
env_file: ./backend/backend.env
|
env_file: ./backend/dev.env
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
restart: always
|
restart: always
|
||||||
|
@ -45,7 +45,7 @@ services:
|
||||||
image: graphile/postgraphile
|
image: graphile/postgraphile
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
env_file: ./backend/backend.env
|
env_file: ./backend/dev.env
|
||||||
ports:
|
ports:
|
||||||
- "5433:5000"
|
- "5433:5000"
|
||||||
command: [
|
command: [
|
||||||
|
|
Loading…
Reference in a new issue