mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Make logout flow more robust.
This commit is contained in:
parent
eae490b0a7
commit
5ea12d469b
@ -21,7 +21,7 @@ const launch_details_text = document.getElementById('launch_details_text')
|
||||
const server_selection_button = document.getElementById('server_selection_button')
|
||||
const user_text = document.getElementById('user_text')
|
||||
|
||||
const loggerLanding = LoggerUtil('%c[Landing]', 'color: #000668; font-weight: bold')
|
||||
const loggerLanding = LoggerUtil1('%c[Landing]', 'color: #000668; font-weight: bold')
|
||||
|
||||
/* Launch Progress Wrapper Functions */
|
||||
|
||||
@ -293,7 +293,7 @@ function asyncSystemScan(mcVersion, launchAfter = true){
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const loggerSysAEx = LoggerUtil('%c[SysAEx]', 'color: #353232; font-weight: bold')
|
||||
const loggerSysAEx = LoggerUtil1('%c[SysAEx]', 'color: #353232; font-weight: bold')
|
||||
|
||||
const forkEnv = JSON.parse(JSON.stringify(process.env))
|
||||
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
|
||||
@ -495,8 +495,8 @@ function dlAsync(login = true){
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const loggerAEx = LoggerUtil('%c[AEx]', 'color: #353232; font-weight: bold')
|
||||
const loggerLaunchSuite = LoggerUtil('%c[LaunchSuite]', 'color: #000668; font-weight: bold')
|
||||
const loggerAEx = LoggerUtil1('%c[AEx]', 'color: #353232; font-weight: bold')
|
||||
const loggerLaunchSuite = LoggerUtil1('%c[LaunchSuite]', 'color: #000668; font-weight: bold')
|
||||
|
||||
const forkEnv = JSON.parse(JSON.stringify(process.env))
|
||||
forkEnv.CONFIG_DIRECT_PATH = ConfigManager.getLauncherDirectory()
|
||||
|
@ -21,7 +21,7 @@ const loginForm = document.getElementById('loginForm')
|
||||
// Control variables.
|
||||
let lu = false, lp = false
|
||||
|
||||
const loggerLogin = LoggerUtil('%c[Login]', 'color: #000668; font-weight: bold')
|
||||
const loggerLogin = LoggerUtil1('%c[Login]', 'color: #000668; font-weight: bold')
|
||||
|
||||
|
||||
/**
|
||||
|
@ -315,6 +315,9 @@ settingsNavDone.onclick = () => {
|
||||
* Account Management Tab
|
||||
*/
|
||||
|
||||
const msftLoginLogger = LoggerUtil.getLogger('Microsoft Login')
|
||||
const msftLogoutLogger = LoggerUtil.getLogger('Microsoft Logout')
|
||||
|
||||
// Bind the add mojang account button.
|
||||
document.getElementById('settingsAddMojangAccount').onclick = (e) => {
|
||||
switchView(getCurrentView(), VIEWS.login, 500, 500, () => {
|
||||
@ -338,8 +341,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => {
|
||||
|
||||
if(arguments_.length > 1 && arguments_[1] === MSFT_ERROR.NOT_FINISHED) {
|
||||
// User cancelled.
|
||||
// TODO Get logger from LoggerUtil
|
||||
console.log('Login Cancelled')
|
||||
msftLoginLogger.info('Login cancelled by user.')
|
||||
return
|
||||
}
|
||||
|
||||
@ -379,8 +381,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGIN, (_, ...arguments_) => {
|
||||
toggleOverlay(true)
|
||||
} else {
|
||||
|
||||
// TODO Update logging message
|
||||
console.log('Acquired authCode')
|
||||
msftLoginLogger.info('Acquired authCode, proceeding with authentication.')
|
||||
|
||||
const authCode = queryMap.code
|
||||
AuthManager.addMicrosoftAccount(authCode).then(value => {
|
||||
@ -483,14 +484,12 @@ function processLogOut(val, isLastAccount){
|
||||
|
||||
// Bind reply for Microsoft Logout.
|
||||
ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => {
|
||||
console.log('on logout, ', arguments_)
|
||||
if (arguments_[0] === MSFT_REPLY_TYPE.ERROR) {
|
||||
switchView(getCurrentView(), VIEWS.settings, 500, 500, () => {
|
||||
|
||||
if(arguments_.length > 1 && arguments_[1] === MSFT_ERROR.NOT_FINISHED) {
|
||||
// User cancelled.
|
||||
// TODO Get logger from LoggerUtil
|
||||
console.log('Logout Cancelled')
|
||||
msftLogoutLogger.info('Logout cancelled by user.')
|
||||
return
|
||||
}
|
||||
|
||||
@ -511,7 +510,7 @@ ipcRenderer.on(MSFT_OPCODE.REPLY_LOGOUT, (_, ...arguments_) => {
|
||||
const isLastAccount = arguments_[2]
|
||||
const prevSelAcc = ConfigManager.getSelectedAccount()
|
||||
|
||||
console.log('Logout Successful. uuid:', uuid)
|
||||
msftLogoutLogger.info('Logout Successful. uuid:', uuid)
|
||||
|
||||
AuthManager.removeMicrosoftAccount(uuid)
|
||||
.then(() => {
|
||||
|
@ -9,11 +9,12 @@ const $ = require('jquery')
|
||||
const {ipcRenderer, shell, webFrame} = require('electron')
|
||||
const remote = require('@electron/remote')
|
||||
const isDev = require('./assets/js/isdev')
|
||||
const LoggerUtil = require('./assets/js/loggerutil')
|
||||
const { LoggerUtil } = require('helios-core')
|
||||
const LoggerUtil1 = require('./assets/js/loggerutil')
|
||||
|
||||
const loggerUICore = LoggerUtil('%c[UICore]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdater = LoggerUtil('%c[AutoUpdater]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdaterSuccess = LoggerUtil('%c[AutoUpdater]', 'color: #209b07; font-weight: bold')
|
||||
const loggerUICore = LoggerUtil1('%c[UICore]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdater = LoggerUtil1('%c[AutoUpdater]', 'color: #000668; font-weight: bold')
|
||||
const loggerAutoUpdaterSuccess = LoggerUtil1('%c[AutoUpdater]', 'color: #209b07; font-weight: bold')
|
||||
|
||||
// Log deprecation and process warnings.
|
||||
process.traceProcessWarnings = true
|
||||
|
22
index.js
22
index.js
@ -145,6 +145,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGIN, (ipcEvent) => {
|
||||
// Microsoft Auth Logout
|
||||
let msftLogoutWindow
|
||||
let msftLogoutSuccess
|
||||
let msftLogoutSuccessSent
|
||||
ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => {
|
||||
if (msftLogoutWindow) {
|
||||
ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.ERROR, MSFT_ERROR.ALREADY_OPEN)
|
||||
@ -152,6 +153,7 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => {
|
||||
}
|
||||
|
||||
msftLogoutSuccess = false
|
||||
msftLogoutSuccessSent = false
|
||||
msftLogoutWindow = new BrowserWindow({
|
||||
title: 'Microsoft Logout',
|
||||
backgroundColor: '#222222',
|
||||
@ -168,21 +170,27 @@ ipcMain.on(MSFT_OPCODE.OPEN_LOGOUT, (ipcEvent, uuid, isLastAccount) => {
|
||||
msftLogoutWindow.on('close', () => {
|
||||
if(!msftLogoutSuccess) {
|
||||
ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.ERROR, MSFT_ERROR.NOT_FINISHED)
|
||||
} else if(!msftLogoutSuccessSent) {
|
||||
msftLogoutSuccessSent = true
|
||||
ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.SUCCESS, uuid, isLastAccount)
|
||||
}
|
||||
})
|
||||
|
||||
msftLogoutWindow.webContents.on('did-navigate', () => {
|
||||
setTimeout(() => {
|
||||
if(msftLogoutWindow) {
|
||||
ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.SUCCESS, uuid, isLastAccount)
|
||||
msftLogoutSuccess = true
|
||||
msftLogoutWindow.webContents.on('did-navigate', (_, uri) => {
|
||||
if(uri.startsWith('https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession')) {
|
||||
msftLogoutSuccess = true
|
||||
setTimeout(() => {
|
||||
if(!msftLogoutSuccessSent) {
|
||||
msftLogoutSuccessSent = true
|
||||
ipcEvent.reply(MSFT_OPCODE.REPLY_LOGOUT, MSFT_REPLY_TYPE.SUCCESS, uuid, isLastAccount)
|
||||
}
|
||||
|
||||
if(msftLogoutWindow) {
|
||||
msftLogoutWindow.close()
|
||||
msftLogoutWindow = null
|
||||
}
|
||||
}
|
||||
}, 5000)
|
||||
}, 5000)
|
||||
}
|
||||
})
|
||||
|
||||
msftLogoutWindow.removeMenu()
|
||||
|
Loading…
Reference in New Issue
Block a user