mirror of
https://github.com/xbgmsharp/postgsail.git
synced 2025-09-17 03:07:47 +00:00
Update migration 202405
- Update api.login add user ip to track multi-user accounts - Update signalk plugin message - Update cron job signalk plugin
This commit is contained in:
@@ -31,6 +31,8 @@ declare
|
|||||||
_email text := email;
|
_email text := email;
|
||||||
_user_id text := null;
|
_user_id text := null;
|
||||||
_user_disable boolean := false;
|
_user_disable boolean := false;
|
||||||
|
headers json := current_setting('request.headers', true)::json;
|
||||||
|
client_ip text := coalesce(headers->>'x-client-ip', NULL);
|
||||||
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;
|
||||||
@@ -63,6 +65,12 @@ begin
|
|||||||
VALUES ('email_otp', _email, now(), _user_id);
|
VALUES ('email_otp', _email, now(), _user_id);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
-- Track IP per user to avoid abuse
|
||||||
|
RAISE WARNING 'api.login debug: [%],[%]', client_ip, login.email;
|
||||||
|
IF client_ip IS NOT NULL THEN
|
||||||
|
UPDATE auth.accounts a SET preferences = jsonb_recursive_merge(a.preferences, jsonb_build_object('ip', client_ip)) WHERE a.email = login.email;
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- Get app_jwt_secret
|
-- Get app_jwt_secret
|
||||||
SELECT value INTO app_jwt_secret
|
SELECT value INTO app_jwt_secret
|
||||||
FROM app_settings
|
FROM app_settings
|
||||||
@@ -420,7 +428,7 @@ COMMENT ON FUNCTION
|
|||||||
IS 'init by pg_cron, check for signalk plugin version and notify for upgrade';
|
IS 'init by pg_cron, check for signalk plugin version and notify for upgrade';
|
||||||
|
|
||||||
INSERT INTO public.email_templates ("name",email_subject,email_content,pushover_title,pushover_message)
|
INSERT INTO public.email_templates ("name",email_subject,email_content,pushover_title,pushover_message)
|
||||||
VALUES ('skplugin_upgrade','PostgSail Signalk plugin upgrade',E'Hello __RECIPIENT__,\nSorry!Please upgrade your postgsail signalk plugin. Be sure to contact me if you encounter any issue.','PostgSail Signalk plugin upgrade!',E'Please upgrade your postgsail signalk plugin.');
|
VALUES ('skplugin_upgrade','PostgSail Signalk plugin upgrade',E'Hello __RECIPIENT__,\nPlease upgrade your postgsail signalk plugin. Be sure to contact me if you encounter any issue.','PostgSail Signalk plugin upgrade!',E'Please upgrade your postgsail signalk plugin.');
|
||||||
|
|
||||||
-- Update version
|
-- Update version
|
||||||
UPDATE public.app_settings
|
UPDATE public.app_settings
|
||||||
@@ -429,7 +437,8 @@ UPDATE public.app_settings
|
|||||||
|
|
||||||
\c postgres
|
\c postgres
|
||||||
|
|
||||||
-- Notifications/Reminders of no vessel & no metadata & no activity
|
-- Notifications/Reminders for old signalk plugin
|
||||||
-- At 08:06 on Sunday.
|
-- At 08:06 on Sunday.
|
||||||
-- At 08:06 on every 4th day-of-month if it's on Sunday.
|
-- At 08:06 on every 4th day-of-month if it's on Sunday.
|
||||||
SELECT cron.schedule('cron_skplugin_upgrade', '6 8 */4 * 0', 'select public.cron_process_skplugin_upgrade_fn()');
|
SELECT cron.schedule('cron_skplugin_upgrade', '6 8 */4 * 0', 'select public.cron_process_skplugin_upgrade_fn()');
|
||||||
|
UPDATE cron.job SET database = 'postgres' WHERE jobname = 'cron_skplugin_upgrade';
|
||||||
|
Reference in New Issue
Block a user