@@ -58,6 +58,16 @@ if (shouldQuit) {
58
58
return ;
59
59
}
60
60
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
+
61
71
function openMainWindow ( ) {
62
72
var windowOpts = {
63
73
'icon' : path . join ( __dirname , process . platform == 'win32' ? 'icon.ico' : 'icon.png' ) ,
@@ -79,19 +89,13 @@ function openMainWindow() {
79
89
mainWindow . maximize ( ) ;
80
90
}
81
91
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
-
90
92
var initialUrl = config . get ( 'host' ) + '/' ;
91
93
if ( ircUrlOnOpen ) {
92
94
initialUrl += '#?/irc_url=' + ircUrlOnOpen ;
93
95
ircUrlOnOpen = null ;
94
96
}
97
+
98
+ enableStreamlinedLogin ( ) ;
95
99
mainWindow . loadURL ( initialUrl ) ;
96
100
97
101
mainWindow . on ( 'closed' , function ( ) {
@@ -144,7 +148,12 @@ function openMainWindow() {
144
148
break ;
145
149
}
146
150
} ) ;
147
-
151
+
152
+ mainWindow . webContents . on ( 'will-navigate' , function ( e , url ) {
153
+ // Make sure the invite cookie persists over logout
154
+ enableStreamlinedLogin ( ) ;
155
+ } ) ;
156
+
148
157
mainWindow . webContents . on ( 'did-navigate-in-page' , function ( e , url ) {
149
158
var historyMenu = menu . items . find ( function ( item ) {
150
159
return item . id == 'history' ;
0 commit comments