mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Integrate Microsoft login option when selected account validation fails.
This commit is contained in:
parent
ce52b520ae
commit
47aaee5214
@ -1,12 +1,14 @@
|
|||||||
const loginOptionsCancelContainer = document.getElementById('loginOptionCancelContainer')
|
const loginOptionsCancelContainer = document.getElementById('loginOptionCancelContainer')
|
||||||
const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft')
|
const loginOptionMicrosoft = document.getElementById('loginOptionMicrosoft')
|
||||||
const loginOptionMojang = document.getElementById('loginOptionMojang')
|
const loginOptionMojang = document.getElementById('loginOptionMojang')
|
||||||
|
const loginOptionsCancelButton = document.getElementById('loginOptionCancelButton')
|
||||||
|
|
||||||
let loginOptionsCancellable = false
|
let loginOptionsCancellable = false
|
||||||
|
|
||||||
let loginOptionsViewOnLoginSuccess
|
let loginOptionsViewOnLoginSuccess
|
||||||
let loginOptionsViewOnLoginCancel
|
let loginOptionsViewOnLoginCancel
|
||||||
let loginOptionsViewOnCancel
|
let loginOptionsViewOnCancel
|
||||||
|
let loginOptionsViewCancelHandler
|
||||||
|
|
||||||
function loginOptionsCancelEnabled(val){
|
function loginOptionsCancelEnabled(val){
|
||||||
if(val){
|
if(val){
|
||||||
@ -33,3 +35,16 @@ loginOptionMojang.onclick = (e) => {
|
|||||||
loginCancelEnabled(true)
|
loginCancelEnabled(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loginOptionsCancelButton.onclick = (e) => {
|
||||||
|
switchView(getCurrentView(), loginOptionsViewOnCancel, 500, 500, () => {
|
||||||
|
// Clear login values (Mojang login)
|
||||||
|
// No cleanup needed for Microsoft.
|
||||||
|
loginUsername.value = ''
|
||||||
|
loginPassword.value = ''
|
||||||
|
if(loginOptionsViewCancelHandler != null){
|
||||||
|
loginOptionsViewCancelHandler()
|
||||||
|
loginOptionsViewCancelHandler = null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -197,6 +197,9 @@ document.getElementById('accountSelectConfirm').addEventListener('click', () =>
|
|||||||
const authAcc = ConfigManager.setSelectedAccount(listings[i].getAttribute('uuid'))
|
const authAcc = ConfigManager.setSelectedAccount(listings[i].getAttribute('uuid'))
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
updateSelectedAccount(authAcc)
|
updateSelectedAccount(authAcc)
|
||||||
|
if(getCurrentView() === VIEWS.settings) {
|
||||||
|
prepareSettings()
|
||||||
|
}
|
||||||
toggleOverlay(false)
|
toggleOverlay(false)
|
||||||
validateSelectedAccount()
|
validateSelectedAccount()
|
||||||
return
|
return
|
||||||
@ -207,6 +210,9 @@ document.getElementById('accountSelectConfirm').addEventListener('click', () =>
|
|||||||
const authAcc = ConfigManager.setSelectedAccount(listings[0].getAttribute('uuid'))
|
const authAcc = ConfigManager.setSelectedAccount(listings[0].getAttribute('uuid'))
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
updateSelectedAccount(authAcc)
|
updateSelectedAccount(authAcc)
|
||||||
|
if(getCurrentView() === VIEWS.settings) {
|
||||||
|
prepareSettings()
|
||||||
|
}
|
||||||
toggleOverlay(false)
|
toggleOverlay(false)
|
||||||
validateSelectedAccount()
|
validateSelectedAccount()
|
||||||
}
|
}
|
||||||
|
@ -334,20 +334,46 @@ async function validateSelectedAccount(){
|
|||||||
'Select Another Account'
|
'Select Another Account'
|
||||||
)
|
)
|
||||||
setOverlayHandler(() => {
|
setOverlayHandler(() => {
|
||||||
|
|
||||||
|
const isMicrosoft = selectedAcc.type === 'microsoft'
|
||||||
|
|
||||||
|
if(isMicrosoft) {
|
||||||
|
// Empty for now
|
||||||
|
} else {
|
||||||
|
// Mojang
|
||||||
|
// For convenience, pre-populate the username of the account.
|
||||||
document.getElementById('loginUsername').value = selectedAcc.username
|
document.getElementById('loginUsername').value = selectedAcc.username
|
||||||
validateEmail(selectedAcc.username)
|
validateEmail(selectedAcc.username)
|
||||||
loginViewOnSuccess = getCurrentView()
|
}
|
||||||
loginViewOnCancel = getCurrentView()
|
|
||||||
if(accLen > 0){
|
loginOptionsViewOnLoginSuccess = getCurrentView()
|
||||||
loginViewCancelHandler = () => {
|
loginOptionsViewOnLoginCancel = VIEWS.loginOptions
|
||||||
|
|
||||||
|
if(accLen > 0) {
|
||||||
|
loginOptionsViewOnCancel = getCurrentView()
|
||||||
|
loginOptionsViewCancelHandler = () => {
|
||||||
|
if(isMicrosoft) {
|
||||||
|
ConfigManager.addMicrosoftAuthAccount(
|
||||||
|
selectedAcc.uuid,
|
||||||
|
selectedAcc.accessToken,
|
||||||
|
selectedAcc.username,
|
||||||
|
selectedAcc.expiresAt,
|
||||||
|
selectedAcc.microsoft.access_token,
|
||||||
|
selectedAcc.microsoft.refresh_token,
|
||||||
|
selectedAcc.microsoft.expires_at
|
||||||
|
)
|
||||||
|
} else {
|
||||||
ConfigManager.addMojangAuthAccount(selectedAcc.uuid, selectedAcc.accessToken, selectedAcc.username, selectedAcc.displayName)
|
ConfigManager.addMojangAuthAccount(selectedAcc.uuid, selectedAcc.accessToken, selectedAcc.username, selectedAcc.displayName)
|
||||||
|
}
|
||||||
ConfigManager.save()
|
ConfigManager.save()
|
||||||
validateSelectedAccount()
|
validateSelectedAccount()
|
||||||
}
|
}
|
||||||
loginCancelEnabled(true)
|
loginOptionsCancelEnabled(true)
|
||||||
|
} else {
|
||||||
|
loginOptionsCancelEnabled(false)
|
||||||
}
|
}
|
||||||
toggleOverlay(false)
|
toggleOverlay(false)
|
||||||
switchView(getCurrentView(), VIEWS.login)
|
switchView(getCurrentView(), VIEWS.loginOptions)
|
||||||
})
|
})
|
||||||
setDismissHandler(() => {
|
setDismissHandler(() => {
|
||||||
if(accLen > 1){
|
if(accLen > 1){
|
||||||
|
Loading…
Reference in New Issue
Block a user