Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix origin migrator for SSO logins #10920

Merged
merged 3 commits into from
Sep 19, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions electron_app/src/originMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ async function migrateFromOldOrigin() {
webgl: false,
},
});
ipcMain.on('origin_migration_complete', (e, success, sentSummary, storedSummary) => {
const onOriginMigrationComplete = (e, success, sentSummary, storedSummary) => {
// we use once but we'll only get once of these events,
dbkr marked this conversation as resolved.
Show resolved Hide resolved
// so remove the listener for the other one
ipcMain.removeListener('origin_migration_nodata', onOriginMigrationNoData);

if (success) {
console.log("Origin migration completed successfully!");
} else {
Expand All @@ -43,12 +47,18 @@ async function migrateFromOldOrigin() {
console.error("Data stored", storedSummary);
migrateWindow.close();
resolve();
});
ipcMain.on('origin_migration_nodata', (e) => {
};
const onOriginMigrationNoData = (e, success, sentSummary, storedSummary) => {
ipcMain.removeListener('origin_migration_complete', onOriginMigrationComplete);

console.log("No session to migrate from old origin");
migrateWindow.close();
resolve();
});
};

ipcMain.once('origin_migration_complete', onOriginMigrationComplete);
ipcMain.once('origin_migration_nodata', onOriginMigrationNoData);

// Normalise the path because in the distribution, __dirname will be inside the
// electron asar.
const sourcePagePath = path.normalize(__dirname + '/../../origin_migrator/source.html');
Expand Down