Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 4688198

Browse files
committed
Make sure invite cookie persists after logout to preserve streamlined login. Fixes #25
1 parent 42a7034 commit 4688198

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

app/main.js

+18-9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ if (shouldQuit) {
5858
return;
5959
}
6060

61+
function enableStreamlinedLogin() {
62+
// Enable the streamlined login page
63+
var inviteCookie = { url : config.get('host'), name : "invite", value : "1" };
64+
mainWindow.webContents.session.cookies.set(inviteCookie, function (error) {
65+
if (error) {
66+
log.error('set invite cookie error', error);
67+
}
68+
});
69+
}
70+
6171
function openMainWindow() {
6272
var windowOpts = {
6373
'icon': path.join(__dirname, process.platform == 'win32' ? 'icon.ico' : 'icon.png'),
@@ -79,19 +89,13 @@ function openMainWindow() {
7989
mainWindow.maximize();
8090
}
8191

82-
// Enable the streamlined login page
83-
var inviteCookie = { url : config.get('host'), name : "invite", value : "1" };
84-
mainWindow.webContents.session.cookies.set(inviteCookie, function (error) {
85-
if (error) {
86-
log.error('set invite cookie error', error);
87-
}
88-
});
89-
9092
var initialUrl = config.get('host') + '/';
9193
if (ircUrlOnOpen) {
9294
initialUrl += '#?/irc_url=' + ircUrlOnOpen;
9395
ircUrlOnOpen = null;
9496
}
97+
98+
enableStreamlinedLogin();
9599
mainWindow.loadURL(initialUrl);
96100

97101
mainWindow.on('closed', function() {
@@ -144,7 +148,12 @@ function openMainWindow() {
144148
break;
145149
}
146150
});
147-
151+
152+
mainWindow.webContents.on('will-navigate', function (e, url) {
153+
// Make sure the invite cookie persists over logout
154+
enableStreamlinedLogin();
155+
});
156+
148157
mainWindow.webContents.on('did-navigate-in-page', function (e, url) {
149158
var historyMenu = menu.items.find(function (item) {
150159
return item.id == 'history';

0 commit comments

Comments
 (0)