From ba353411150e69aa1fed2da6d6a59efb974f4c77 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Mon, 5 Oct 2020 13:30:04 -0700 Subject: [PATCH 1/2] fix(plg): add postMessage listener PREFLIGHT_REQUEST --- dynamix.unraid.net.plg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dynamix.unraid.net.plg b/dynamix.unraid.net.plg index b0d652928..0762db73f 100644 --- a/dynamix.unraid.net.plg +++ b/dynamix.unraid.net.plg @@ -1026,6 +1026,8 @@ function handleMessage(e) { return window.location.href = '/Main'; case "STOP_SENDING_SESSION": break; + case "PREFLIGHT_REQUEST": + break; default: console.error('Unhandled event \'' + data.event + '\' fired. data:', data); break; From 8d2c83115fe52cc9bcc88d92a65212d0152ef9e4 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Tue, 6 Oct 2020 17:20:11 -0700 Subject: [PATCH 2/2] fix: postMessage ping backs to regwiz --- dynamix.unraid.net.plg | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dynamix.unraid.net.plg b/dynamix.unraid.net.plg index 0762db73f..df2f7724a 100644 --- a/dynamix.unraid.net.plg +++ b/dynamix.unraid.net.plg @@ -952,17 +952,19 @@ function handleMessage(e) { $.get('/webGui/include/InstallKey.php', {url: data.license}, function() { console.log('New license key installed: ' + data.license); const payload = { - event: 'LICENSE_SUCCESS', + event: 'LICENSE_PINGBACK', message: 'New license key installed', license: data.license, + success: true, }; e.source.postMessage(JSON.stringify(payload), e.origin); }).fail(function() { console.error('Failed to license new key: ' + data.license); const payload = { - event: 'LICENSE_ERROR', + event: 'LICENSE_PINGBACK', message: 'Failed to license new key', license: data.license, + success: false, }; e.source.postMessage(JSON.stringify(payload), e.origin); }); @@ -993,11 +995,20 @@ function handleMessage(e) { } $.post('/update.php', postargs, function() { console.log('dynamix/dynamix.cfg: Updated apikey under [remote] section'); + // send a ping back to the regwiz + const payload = { event: 'ACCOUNT_PINGBACK', success: true, type: 'signIn', }; + e.source.postMessage(JSON.stringify(payload), e.origin); }).fail(function() { console.error('Failed to update apikey under [remote] section'); + // send a ping back to the regwiz + const payload = { event: 'ACCOUNT_PINGBACK', success: false, type: 'signIn', }; + e.source.postMessage(JSON.stringify(payload), e.origin); }); }).fail(function() { console.error('Failed to retrieve details from key server'); + // send a ping back to the regwiz + const payload = { event: 'ACCOUNT_PINGBACK', success: false, type: 'signIn', }; + e.source.postMessage(JSON.stringify(payload), e.origin); }); } // duplicate conditional so we don't get the error from HANDLE_LICENSES() @@ -1016,8 +1027,14 @@ function handleMessage(e) { case "MYSERVERS_UNREGISTER": $.post('/update.php', {'#file': 'dynamix/dynamix.cfg', '#section': 'remote', apikey: '', username: '', avatar: ''}, function() { console.log('dynamix/dynamix.cfg: Unregistered myservers, cleared apikey under [remote] section'); + // send a ping back to the regwiz + const payload = { event: 'ACCOUNT_PINGBACK', success: true, type: 'signOut', }; + e.source.postMessage(JSON.stringify(payload), e.origin); }).fail(function() { console.error('Failed to unregister'); + // send a ping back to the regwiz + const payload = { event: 'ACCOUNT_PINGBACK', success: false, type: 'signOut', }; + e.source.postMessage(JSON.stringify(payload), e.origin); }); break; case "RELOAD":