Clean Citizen entities
Change plainPassword to just password Add request Input for /login
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
$$;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user