fix: hashed_text and email are text newtypes
This commit is contained in:
parent
7a4d728337
commit
c19a46b736
@ -1 +1 @@
|
||||
create type public.email as (email text);
|
||||
select create_newtype_text('public.email');
|
||||
|
@ -1,10 +1,4 @@
|
||||
create type hashed_text as (hashed text);
|
||||
|
||||
create function hashed_text_string(hashed hashed_text)
|
||||
returns text
|
||||
language sql
|
||||
immutable
|
||||
as 'select (hashed.hashed);';
|
||||
select create_newtype_text('public.hashed_text');
|
||||
|
||||
create function hash_text(plain text)
|
||||
returns hashed_text
|
||||
@ -12,7 +6,7 @@ create function hash_text(plain text)
|
||||
immutable
|
||||
as $$
|
||||
begin
|
||||
return row(crypt(plain, gen_salt('bf')));
|
||||
return hashed_text_of_string(crypt(plain, gen_salt('bf')));
|
||||
end;
|
||||
$$;
|
||||
|
||||
@ -22,6 +16,6 @@ create function hashed_text_matches(plain text, hashed hashed_text)
|
||||
immutable
|
||||
as $$
|
||||
begin
|
||||
return hashed_text_string(hashed) = crypt(plain, hashed_text_string(hashed));
|
||||
return hashed_text_to_string(hashed) = crypt(plain, hashed_text_to_string(hashed));
|
||||
end;
|
||||
$$;
|
||||
|
Loading…
Reference in New Issue
Block a user