Electron-253 - Fixed an issue with clearing up the auth settings

This commit is contained in:
Kiran Niranjan 2017-12-22 10:51:28 +05:30 committed by Kiran Niranjan
parent cb669602ed
commit 025738bb2c

View File

@ -111,18 +111,12 @@ function openBasicAuthWindow(windowName, hostname, isValidCredentials, clearSett
ipc.on('login', (event, args) => {
if (typeof args === 'object' && typeof local.authCallback === 'function') {
local.authCallback(args.username, args.password);
basicAuthWindow.close();
closeAuthWindow(false);
}
});
ipc.on('close-basic-auth', () => {
if (typeof local.clearSettings === 'function') {
local.clearSettings();
}
if (basicAuthWindow) {
basicAuthWindow.close();
}
closeAuthWindow(true);
});
/**
@ -132,6 +126,19 @@ function destroyWindow() {
basicAuthWindow = null;
}
/**
* Method to close the auth window
* @param {boolean} clearSettings - Whether to clear the auth settings
*/
function closeAuthWindow(clearSettings) {
if (clearSettings && typeof local.clearSettings === 'function') {
local.clearSettings();
}
if (basicAuthWindow) {
basicAuthWindow.close();
}
}
module.exports = {
openBasicAuthWindow: openBasicAuthWindow