MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / showMasterPassword

Function showMasterPassword

web/pgadmin/static/js/Dialogs/index.jsx:105–180  ·  view source on GitHub ↗
(isPWDPresent, errmsg, masterpass_callback_queue, cancel_callback, keyring_name='', master_password_hook='')

Source from the content-addressed store, hash-verified

103
104// This functions is used to show the master password dialog.
105export function showMasterPassword(isPWDPresent, errmsg, masterpass_callback_queue, cancel_callback, keyring_name='', master_password_hook='') {
106 const api = getApiInstance();
107 let title = gettext('Set Master Password');
108 if (keyring_name.length > 0)
109 title = gettext('Migrate Saved Passwords');
110 else if (isPWDPresent)
111 title = gettext('Unlock Saved Passwords');
112
113 if(master_password_hook){
114 if(errmsg){
115 pgAdmin.Browser.notifier.errorText(errmsg);
116 return true;
117 }else{
118 pgAdmin.Browser.notifier.confirm(gettext('Reset Master Password'),
119 gettext('The master password retrieved from the master password hook utility is different from what was previously retrieved.') + '<br>'
120 + gettext('Do you want to reset your master password to match?') + '<br><br>'
121 + gettext('Note that this will close all open database connections and remove all saved passwords.'),
122 function() {
123 let _url = url_for('browser.reset_master_password');
124 const api = getApiInstance();
125 api.delete(_url)
126 .then(() => {
127 pgAdmin.Browser.notifier.info('The master password has been reset.');
128 })
129 .catch((err) => {
130 pgAdmin.Browser.notifier.errorText(err.message);
131 });
132 return true;
133 },
134 function() {/* If user clicks No */ return true;}
135 );}
136 }else{
137
138 pgAdmin.Browser.notifier.showModal(title, (onClose)=> {
139 return (
140 <MasterPasswordContent
141 isPWDPresent= {isPWDPresent}
142 data={{'errmsg': errmsg}}
143 keyringName={keyring_name}
144 closeModal={() => {
145 onClose();
146 }}
147 onResetPassowrd={(isKeyRing=false)=>{
148 pgAdmin.Browser.notifier.confirm(gettext('Reset Master Password'),
149 gettext('This will remove all the saved passwords. This will also remove established connections to '
150 + 'the server and you may need to reconnect again. Do you wish to continue?'),
151 function() {
152 let _url = url_for('browser.reset_master_password');
153
154 api.delete(_url)
155 .then(() => {
156 onClose();
157 if(!isKeyRing) {
158 showMasterPassword(false, null, masterpass_callback_queue, cancel_callback);
159 }
160 })
161 .catch((err) => {
162 pgAdmin.Browser.notifier.errorText(err.message);

Callers 1

checkMasterPasswordFunction · 0.85

Calls 9

getApiInstanceFunction · 0.85
gettextFunction · 0.85
checkMasterPasswordFunction · 0.85
errorTextMethod · 0.80
confirmMethod · 0.80
infoMethod · 0.80
showModalMethod · 0.80
onCloseFunction · 0.70
deleteMethod · 0.45

Tested by

no test coverage detected