diff --git a/docs/en_US/release_notes_6_8.rst b/docs/en_US/release_notes_6_8.rst index 34924d93c..6be5598e1 100644 --- a/docs/en_US/release_notes_6_8.rst +++ b/docs/en_US/release_notes_6_8.rst @@ -24,6 +24,7 @@ Bug fixes | `Issue #4256 `_ - Fixed an issue where SQL for revoke statements are not shown for databases. | `Issue #5836 `_ - Adds a new LDAP authentication configuration parameter that indicates the case sensitivity of the LDAP schema/server. + | `Issue #6960 `_ - Ensure that the master password dialog is popped up if the crypt key is missing. | `Issue #7059 `_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2. | `Issue #7176 `_ - Fixed an issue where the browser tree state was not preserved correctly. | `Issue #7197 `_ - Fixed an issue where foreign key relationships do not update when the primary key is modified. diff --git a/web/pgadmin/browser/static/js/browser.js b/web/pgadmin/browser/static/js/browser.js index 4794effed..8e14d1a25 100644 --- a/web/pgadmin/browser/static/js/browser.js +++ b/web/pgadmin/browser/static/js/browser.js @@ -634,6 +634,7 @@ define('pgadmin.browser', [ } else if(event.index == 2) { /* Cancel button */ self.masterpass_callback_queue = []; + self.cancel_callback(); } else if(event.index == 1) { /* Reset Button */ event.cancel = true; @@ -698,7 +699,9 @@ define('pgadmin.browser', [ }); }, - set_master_password: function(password='', button_click=false, set_callback=()=>{/*This is intentional (SonarQube)*/}) { + set_master_password: function(password='', button_click=false, + set_callback=()=>{/*This is intentional (SonarQube)*/}, + cancel_callback=()=>{/*This is intentional (SonarQube)*/}) { let data=null, self = this; data = JSON.stringify({ @@ -707,6 +710,7 @@ define('pgadmin.browser', [ }); self.masterpass_callback_queue.push(set_callback); + self.cancel_callback = cancel_callback; $.ajax({ url: url_for('browser.set_master_password'), diff --git a/web/pgadmin/browser/static/js/node_view.jsx b/web/pgadmin/browser/static/js/node_view.jsx index 453f20c95..7681024c0 100644 --- a/web/pgadmin/browser/static/js/node_view.jsx +++ b/web/pgadmin/browser/static/js/node_view.jsx @@ -61,7 +61,25 @@ export function getNodeView(nodeType, treeNodeInfo, actionType, itemNodeData, fo } else if(err.message){ console.error('error msg', err.message); } - reject(err); + + if (err?.response?.data?.info == 'CRYPTKEY_MISSING') { + Notify.pgNotifier('error', err.request, 'The master password is not set', function(msg) { + setTimeout(function() { + if (msg == 'CRYPTKEY_SET') { + resolve(initData()); + } else if (msg == 'CRYPTKEY_NOT_SET') { + reject(err); + } + }, 100); + }); + } else if (err?.response?.data?.errormsg) { + Notify.alert( + gettext(err.response.statusText), + gettext(err.response.data.errormsg) + ); + + reject(err); + } }); } }); diff --git a/web/pgadmin/misc/statistics/static/js/Statistics.jsx b/web/pgadmin/misc/statistics/static/js/Statistics.jsx index 305262680..90f30c523 100644 --- a/web/pgadmin/misc/statistics/static/js/Statistics.jsx +++ b/web/pgadmin/misc/statistics/static/js/Statistics.jsx @@ -190,14 +190,27 @@ export default function Statistics({ nodeData, item, node, ...props }) { } setLoaderText(''); }) - .catch((e) => { - Notify.alert( - gettext('Failed to retrieve data from the server.'), - gettext(e.message) - ); + .catch((err) => { // show failed message. setLoaderText(''); - setMsg(gettext('Failed to retrieve data from the server.')); + + if (err?.response?.data?.info == 'CRYPTKEY_MISSING') { + Notify.pgNotifier('error', err.request, 'The master password is not set', function(msg) { + setTimeout(function() { + if (msg == 'CRYPTKEY_SET') { + setMsg('No statistics are available for the selected object.'); + } else if (msg == 'CRYPTKEY_NOT_SET') { + setMsg(gettext('The master password is not set.')); + } + }, 100); + }); + } else { + Notify.alert( + gettext('Failed to retrieve data from the server.'), + gettext(err.message) + ); + setMsg(gettext('Failed to retrieve data from the server.')); + } }); } else { setLoaderText(''); diff --git a/web/pgadmin/static/js/SchemaView/index.jsx b/web/pgadmin/static/js/SchemaView/index.jsx index 852e1498d..ec6df7d17 100644 --- a/web/pgadmin/static/js/SchemaView/index.jsx +++ b/web/pgadmin/static/js/SchemaView/index.jsx @@ -530,17 +530,11 @@ function SchemaDialogView({ }); setFormReady(true); setLoaderText(''); - }).catch((err)=>{ + }).catch(()=>{ if(unmounted) { return; } setLoaderText(''); - if (err.response && err.response.data && err.response.data.errormsg) { - Notify.alert( - gettext(err.response.statusText), - gettext(err.response.data.errormsg) - ); - } }); /* Clear the focus timeout if unmounted */ return ()=>{ @@ -819,14 +813,8 @@ function SchemaPropertiesView({ setOrigData(data || {}); setLoaderText(''); } - }).catch((err)=>{ + }).catch(()=>{ setLoaderText(''); - if (err.response && err.response.data && err.response.data.errormsg) { - Notify.alert( - gettext(err.response.statusText), - gettext(err.response.data.errormsg) - ); - } }); }, [getInitData]); diff --git a/web/pgadmin/static/js/helpers/Notifier.jsx b/web/pgadmin/static/js/helpers/Notifier.jsx index af11762f8..c54d00cdd 100644 --- a/web/pgadmin/static/js/helpers/Notifier.jsx +++ b/web/pgadmin/static/js/helpers/Notifier.jsx @@ -196,10 +196,14 @@ var Notifier = { if(resp.info == 'CRYPTKEY_MISSING') { var pgBrowser = window.pgAdmin.Browser; - pgBrowser.set_master_password('', ()=> { + pgBrowser.set_master_password('', false, ()=> { if(onJSONResult && typeof(onJSONResult) == 'function') { onJSONResult('CRYPTKEY_SET'); } + }, ()=> { + if(onJSONResult && typeof(onJSONResult) == 'function') { + onJSONResult('CRYPTKEY_NOT_SET'); + } }); return; } else if (resp.result != null && (!resp.errormsg || resp.errormsg == '') &&