Only serve origin migrator whilst migrating

as per comment
This commit is contained in:
David Baker 2018-12-21 22:21:06 +00:00
parent 751a1dc543
commit 62a49af23f
1 changed files with 8 additions and 1 deletions

View File

@ -36,6 +36,11 @@ const { migrateFromOldOrigin } = require('./originMigrator');
const windowStateKeeper = require('electron-window-state'); const windowStateKeeper = require('electron-window-state');
// boolean flag set whilst we are doing one-time origin migration
// We only serve the origin migration script while we're actually
// migrating to mitigate any risk of it being used maliciously.
let migratingOrigin = false;
if (argv['profile']) { if (argv['profile']) {
app.setPath('userData', `${app.getPath('userData')}-${argv['profile']}`); app.setPath('userData', `${app.getPath('userData')}-${argv['profile']}`);
} }
@ -143,7 +148,9 @@ ipcMain.on('ipcCall', async function(ev, payload) {
mainWindow.focus(); mainWindow.focus();
} }
case 'origin_migrate': case 'origin_migrate':
migratingOrigin = true;
await migrateFromOldOrigin(); await migrateFromOldOrigin();
migratingOrigin = false;
break; break;
default: default:
mainWindow.webContents.send('ipcReply', { mainWindow.webContents.send('ipcReply', {
@ -227,7 +234,7 @@ app.on('ready', () => {
let baseDir; let baseDir;
// first part of the path determines where we serve from // first part of the path determines where we serve from
if (target[1] === 'origin_migrator_dest') { if (migratingOrigin && target[1] === 'origin_migrator_dest') {
// the origin migrator destination page // the origin migrator destination page
// (only the destination script needs to come from the // (only the destination script needs to come from the
// custom protocol: the source part is loaded from a // custom protocol: the source part is loaded from a