SDA-4150: Non-Browser Login will be able to login normally (#1847)

This commit is contained in:
NguyenTranHoangSym 2023-04-07 15:45:06 +07:00 committed by Salah Benmoussati
parent 8c0ae96edc
commit aa03d1d5ff

View File

@ -421,6 +421,8 @@ ipcMain.on(
? userConfigURL ? userConfigURL
: globalConfigURL; : globalConfigURL;
const { subdomain, domain, tld } = whitelistHandler.parseDomain(podUrl); const { subdomain, domain, tld } = whitelistHandler.parseDomain(podUrl);
const localConfig = config.getConfigFields(['enableBrowserLogin']);
formattedPodUrl = `https://${subdomain}.${domain}${tld}`; formattedPodUrl = `https://${subdomain}.${domain}${tld}`;
loginUrl = getBrowserLoginUrl(formattedPodUrl); loginUrl = getBrowserLoginUrl(formattedPodUrl);
logger.info( logger.info(
@ -428,7 +430,27 @@ ipcMain.on(
'check if sso is enabled for the pod', 'check if sso is enabled for the pod',
formattedPodUrl, formattedPodUrl,
); );
loadPodUrl();
if (localConfig.enableBrowserLogin) {
logger.info(
'main-api-handler:',
'check if sso is enabled for the pod',
formattedPodUrl,
);
loadPodUrl(false);
} else {
logger.info(
'main-api-handler:',
'browser login is not enabled - loading main window with',
formattedPodUrl,
);
const mainWebContents = windowHandler.getMainWebContents();
if (mainWebContents && !mainWebContents.isDestroyed()) {
windowHandler.setMainWindowOrigin(formattedPodUrl);
mainWebContents.loadURL(formattedPodUrl);
}
}
break; break;
case apiCmds.setBroadcastMessage: case apiCmds.setBroadcastMessage:
if (swiftSearchInstance) { if (swiftSearchInstance) {
@ -673,17 +695,6 @@ const loadPodUrl = (proxyLogin = false) => {
loginUrl, loginUrl,
); );
await shell.openExternal(loginUrl); await shell.openExternal(loginUrl);
} else {
logger.info(
'main-api-handler:',
'browser login is not enabled - loading main window with',
formattedPodUrl,
);
const mainWebContents = windowHandler.getMainWebContents();
if (mainWebContents && !mainWebContents.isDestroyed()) {
windowHandler.setMainWindowOrigin(formattedPodUrl);
mainWebContents.loadURL(formattedPodUrl);
}
} }
}) })
.catch(async (error) => { .catch(async (error) => {