@@ -81,9 +81,12 @@ export class AuthService {
8181 await AuthService . logout ( )
8282 } )
8383
84- ipcMain . on ( 'getAccessToken' , async ( ) => {
84+ ipcMain . on ( 'getAccessToken' , async ( event , reset : boolean = false ) => {
8585 log . info ( 'storeb' , store . store )
8686 log . info ( '(<any>global).share.auth' , ( < any > global ) . share . auth )
87+ if ( reset ) {
88+ await AuthService . logout ( false )
89+ }
8790 await AuthService . authWithMicrosoft ( )
8891 } )
8992
@@ -187,7 +190,7 @@ export class AuthService {
187190 await AuthService . authWithMicrosoft ( ! changeAccount )
188191 return
189192 }
190- console . log ( 'transparent' , transparent )
193+ // console.log('transparent', transparent)
191194 await AuthService . saveUserInfos ( accessToken , refreshToken , mcInfo , transparent )
192195 }
193196
@@ -223,7 +226,7 @@ export class AuthService {
223226 sendLoginWindowWebContent ( 'setLoginBtn' , false )
224227 }
225228 } )
226- console . log ( 'authHandler.forwardUrl' , authHandler . forwardUrl )
229+ // console.log('authHandler.forwardUrl', authHandler.forwardUrl)
227230 // noinspection ES6MissingAwait
228231 authWindow . loadURL ( authHandler . forwardUrl )
229232 const filter = { urls : [ REDIRECT_URL ] }
@@ -232,7 +235,7 @@ export class AuthService {
232235 authWindowclosedByUser = false
233236 authWindow . close ( )
234237 const code = details . url . split ( '=' ) [ 1 ] . split ( '&' ) [ 0 ]
235- console . log ( 'code' , code )
238+ // console.log('code', code)
236239 if ( ! code ) {
237240 log . error ( 'ERROR: The MC code is null.' )
238241 sendLoginWindowWebContent ( 'setLoginBtn' , false )
@@ -265,7 +268,7 @@ export class AuthService {
265268
266269 public static async refreshCurrentAccessToken ( ) : Promise < void > {
267270 const currAccount = store . get ( 'current-account' )
268- console . log ( 'currAccount' , currAccount )
271+ // console.log('currAccount', currAccount)
269272 const accounts : any = store . get ( 'accounts' )
270273 const index = accounts . findIndex ( ( account : any ) => account . username === currAccount )
271274 await AuthService . loginUser ( accounts [ index ] , false , true )
@@ -280,15 +283,18 @@ export class AuthService {
280283 }
281284 }
282285
283- public static async logout ( ) : Promise < void > {
286+ public static async logout ( recreateWindow : boolean = true ) : Promise < void > {
284287 store . set ( 'current-account' , null )
285288 ; ( < any > global ) . share . auth . access_token = ''
286289 ; ( < any > global ) . share . auth . xuid = ''
287290 ; ( < any > global ) . share . auth . uuid = ''
288291 ; ( < any > global ) . share . auth . name = ''
289292 await session . defaultSession . clearCache ( )
290293 await session . defaultSession . clearStorageData ( )
291- await createLoginWindow ( )
292- destroyMainWindow ( )
294+
295+ if ( recreateWindow ) {
296+ await createLoginWindow ( )
297+ destroyMainWindow ( )
298+ }
293299 }
294300}
0 commit comments