mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 11:17:46 +00:00
Enforce OTP verification on login
This commit is contained in:
@@ -172,6 +172,8 @@ declare
|
|||||||
_role name;
|
_role name;
|
||||||
result auth.jwt_token;
|
result auth.jwt_token;
|
||||||
app_jwt_secret text;
|
app_jwt_secret text;
|
||||||
|
_email_valid boolean := false;
|
||||||
|
_email text := email;
|
||||||
begin
|
begin
|
||||||
-- check email and password
|
-- check email and password
|
||||||
select auth.user_role(email, pass) into _role;
|
select auth.user_role(email, pass) into _role;
|
||||||
@@ -184,6 +186,16 @@ begin
|
|||||||
FROM app_settings
|
FROM app_settings
|
||||||
WHERE name = 'app.jwt_secret';
|
WHERE name = 'app.jwt_secret';
|
||||||
|
|
||||||
|
-- Check email_valid and generate OTP
|
||||||
|
SELECT preferences['email_valid'] INTO _email_valid
|
||||||
|
FROM auth.accounts a
|
||||||
|
WHERE a.email = _email;
|
||||||
|
IF _email_valid is null or _email_valid is False THEN
|
||||||
|
INSERT INTO process_queue (channel, payload, stored)
|
||||||
|
VALUES ('email_otp', email, now());
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Generate jwt
|
||||||
select jwt.sign(
|
select jwt.sign(
|
||||||
-- row_to_json(r), ''
|
-- row_to_json(r), ''
|
||||||
-- row_to_json(r)::json, current_setting('app.jwt_secret')::text
|
-- row_to_json(r)::json, current_setting('app.jwt_secret')::text
|
||||||
|
Reference in New Issue
Block a user