./migrations/94501b7_to_047a51b.sql
This commit is contained in:
parent
447e223547
commit
e3283d6fdf
34
94501b7_to_047a51b.sql
Normal file
34
94501b7_to_047a51b.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
create extension if not exists "pgcrypto" with schema "public" version '1.3';
|
||||||
|
|
||||||
|
set check_function_bodies = off;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION public.hash_text(plain text)
|
||||||
|
RETURNS hashed_text
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
IMMUTABLE
|
||||||
|
AS $function$
|
||||||
|
begin
|
||||||
|
return row(crypt(plain, gen_salt('bf')));
|
||||||
|
end;
|
||||||
|
$function$
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION public.hashed_text_matches(plain text, hashed hashed_text)
|
||||||
|
RETURNS boolean
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
IMMUTABLE
|
||||||
|
AS $function$
|
||||||
|
begin
|
||||||
|
return hashed_text_string(hashed) = crypt(plain, hashed_text_string(hashed));
|
||||||
|
end;
|
||||||
|
$function$
|
||||||
|
;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION public.hashed_text_string(hashed hashed_text)
|
||||||
|
RETURNS text
|
||||||
|
LANGUAGE sql
|
||||||
|
IMMUTABLE
|
||||||
|
AS $function$select (hashed.hashed);$function$
|
||||||
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user