Ensure that the master password dialog is popped up if the crypt key is missing. Fixes #6960

This commit is contained in:
Akshay Joshi 2022-04-04 17:00:18 +05:30
parent ae7059aec1
commit 38278c179e
6 changed files with 51 additions and 23 deletions

View File

@ -24,6 +24,7 @@ Bug fixes
| `Issue #4256 <https://redmine.postgresql.org/issues/4256>`_ - Fixed an issue where SQL for revoke statements are not shown for databases.
| `Issue #5836 <https://redmine.postgresql.org/issues/5836>`_ - Adds a new LDAP authentication configuration parameter that indicates the case sensitivity of the LDAP schema/server.
| `Issue #6960 <https://redmine.postgresql.org/issues/6960>`_ - Ensure that the master password dialog is popped up if the crypt key is missing.
| `Issue #7059 <https://redmine.postgresql.org/issues/7059>`_ - Fixed an issue where the error is shown on logout when the authentication source is oauth2.
| `Issue #7176 <https://redmine.postgresql.org/issues/7176>`_ - Fixed an issue where the browser tree state was not preserved correctly.
| `Issue #7197 <https://redmine.postgresql.org/issues/7197>`_ - Fixed an issue where foreign key relationships do not update when the primary key is modified.

View File

@ -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'),

View File

@ -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);
}
});
}
});

View File

@ -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('');

View File

@ -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]);

View File

@ -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 == '') &&