Clean Citizen entities

Change plainPassword to just password
Add request Input for /login
This commit is contained in:
2021-02-09 00:39:26 +01:00
parent 905330a722
commit dcf35eaccd
21 changed files with 114 additions and 87 deletions

View File

@@ -2,7 +2,7 @@ create or replace function change_user_password(resource json) returns void lang
$$
begin
update "user"
set password = crypt(resource->>'plain_password', gen_salt('bf', 8))
set password = crypt(resource->>'password', gen_salt('bf', 8))
where id = (resource->>'id')::uuid;
return;

View File

@@ -1,7 +1,5 @@
create or replace function check_user(in username text, in plain_password text, out resource json) language plpgsql as
create or replace function check_user(in _username text, in _password text, out resource json) language plpgsql as
$$
declare
_username alias for username;
begin
select
case when count(u) = 1
@@ -10,7 +8,7 @@ begin
into resource
from "user" as u
where u.username = lower(_username)
and u.password = crypt(plain_password, u.password)
and u.password = crypt(_password, u.password)
group by u;
end;
$$;

View File

@@ -7,7 +7,7 @@ begin
select
coalesce(t.id, uuid_generate_v4()),
t.username,
crypt(resource->>'plain_password', gen_salt('bf', 8)),
crypt(resource->>'password', gen_salt('bf', 8)),
case when t.blocked_at is not null then now() else null end,
t.roles
from json_populate_record(null::"user", resource) t