make login window closable
This commit is contained in:
parent
efe3a4e643
commit
b4249e7108
@ -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')) {
|
||||
|
13
index.js
13
index.js
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user