make login window closable

This commit is contained in:
Dr_Dee 2021-02-02 14:52:44 +01:00
parent efe3a4e643
commit b4249e7108
2 changed files with 51 additions and 29 deletions

View File

@ -307,6 +307,8 @@ loginMSButton.addEventListener('click', (event) => {
ipcRenderer.on('MSALoginWindowReply', (event, ...args) => {
if (args[0] === 'error') {
switch (args[1]){
case 'AlreadyOpenException': {
setOverlayContent('ERROR', 'There is already a login window open!', 'OK')
setOverlayHandler(() => {
toggleOverlay(false)
@ -314,6 +316,17 @@ ipcRenderer.on('MSALoginWindowReply', (event, ...args) => {
toggleOverlay(true)
return
}
case 'AuthNotFinished': {
setOverlayContent('ERROR', 'You have to finish the login process to use Helios Launcher. The window will close by itself when you have successfully logged in.', 'OK')
setOverlayHandler(() => {
toggleOverlay(false)
})
toggleOverlay(true)
return
}
}
}
const queryMap = args[0]
if (queryMap.has('error')) {

View File

@ -89,11 +89,13 @@ ipcMain.on('distributionIndexDone', (event, res) => {
app.disableHardwareAcceleration()
let MSALoginWindow = null
let login = false
// Open the Microsoft Account Login window
ipcMain.on('openMSALoginWindow', (ipcEvent, args) => {
login = false
if (MSALoginWindow != null) {
ipcEvent.sender.send('MSALoginWindowNotification', 'error', 'AlreadyOpenException')
ipcEvent.reply('MSALoginWindowReply', 'error', 'AlreadyOpenException')
return
}
MSALoginWindow = new BrowserWindow({
@ -101,15 +103,22 @@ ipcMain.on('openMSALoginWindow', (ipcEvent, args) => {
backgroundColor: '#222222',
width: 520,
height: 600,
frame: false,
frame: true,
icon: getPlatformIcon('SealCircle')
})
MSALoginWindow.on('closed', () => {
MSALoginWindow = null
})
MSALoginWindow.on('close', event => {
ipcEvent.reply('MSALoginWindowReply', 'error', 'AuthNotFinished')
})
MSALoginWindow.webContents.on('did-navigate', (event, uri, responseCode, statusText) => {
login = true
if (uri.startsWith(redirectUriPrefix)) {
let querys = uri.substring(redirectUriPrefix.length).split('#', 1).toString().split('&')
let queryMap = new Map()