mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
Electron-217
Added a warning dialog Updated to read method to read only from global config
This commit is contained in:
parent
d7f62a38b0
commit
919882a5b3
@ -425,6 +425,9 @@ module.exports = {
|
||||
saveUserConfig,
|
||||
clearCachedConfigs,
|
||||
|
||||
readConfigFileSync
|
||||
readConfigFileSync,
|
||||
|
||||
// use only if you specifically need to read global config fields
|
||||
getGlobalConfigField,
|
||||
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { getConfigField } = require('./../config.js');
|
||||
const { getGlobalConfigField } = require('./../config.js');
|
||||
const parseDomain = require('parse-domain');
|
||||
const isEqual = require('lodash.isequal');
|
||||
|
||||
@ -12,7 +12,7 @@ const isEqual = require('lodash.isequal');
|
||||
function isWhiteList(url) {
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
getConfigField('whiteListURL').then((whiteList) => {
|
||||
getGlobalConfigField('whiteListURL').then((whiteList) => {
|
||||
|
||||
if (checkWhiteList(url, whiteList)) {
|
||||
return resolve();
|
||||
|
@ -463,11 +463,18 @@ function doCreateMainWindow(initialUrl, initialBounds) {
|
||||
}
|
||||
});
|
||||
|
||||
mainWindow.webContents.on('will-navigate', function(event, navigatedUrl){
|
||||
// TODO: need inputs from design to implement error dialog
|
||||
isWhiteList(navigatedUrl).catch(() => {
|
||||
event.preventDefault();
|
||||
});
|
||||
// whenever the main window is navigated for ex: window.location.href or url redirect
|
||||
mainWindow.webContents.on('will-navigate', function(event, navigatedURL) {
|
||||
isWhiteList(navigatedURL)
|
||||
.catch(() => {
|
||||
event.preventDefault();
|
||||
electron.dialog.showMessageBox(mainWindow, {
|
||||
type: 'warning',
|
||||
buttons: [ 'Ok' ],
|
||||
title: 'Not Allowed',
|
||||
message: `Sorry, you are not allowed to access this website (${navigatedURL}), please contact your administrator for more details`,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user