Show a meaningful message if users try to login without a paid account.
This commit is contained in:
parent
c74e3f0676
commit
6d1ecd73ee
@ -29,12 +29,17 @@ const loggerSuccess = LoggerUtil('%c[AuthManager]', 'color: #209b07; font-weight
|
|||||||
exports.addAccount = async function(username, password){
|
exports.addAccount = async function(username, password){
|
||||||
try {
|
try {
|
||||||
const session = await Mojang.authenticate(username, password, ConfigManager.getClientToken())
|
const session = await Mojang.authenticate(username, password, ConfigManager.getClientToken())
|
||||||
const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name)
|
if(session.selectedProfile != null){
|
||||||
if(ConfigManager.getClientToken() == null){
|
const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name)
|
||||||
ConfigManager.setClientToken(session.clientToken)
|
if(ConfigManager.getClientToken() == null){
|
||||||
|
ConfigManager.setClientToken(session.clientToken)
|
||||||
|
}
|
||||||
|
ConfigManager.save()
|
||||||
|
return ret
|
||||||
|
} else {
|
||||||
|
throw new Error('NotPaidAccount')
|
||||||
}
|
}
|
||||||
ConfigManager.save()
|
|
||||||
return ret
|
|
||||||
} catch (err){
|
} catch (err){
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
}
|
}
|
||||||
|
@ -206,10 +206,17 @@ function resolveError(err){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(err.message != null){
|
if(err.message != null){
|
||||||
// Unknown error with request.
|
if(err.message === 'NotPaidAccount'){
|
||||||
return {
|
return {
|
||||||
title: 'Error During Login:<br>Unknown Error',
|
title: 'Error During Login:<br>Game Not Purchased',
|
||||||
desc: err.message
|
desc: 'The account you are trying to login with has not purchased a copy of Minecraft.<br>You may purchase a copy on <a href="https://minecraft.net/">Minecraft.net</a>'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unknown error with request.
|
||||||
|
return {
|
||||||
|
title: 'Error During Login:<br>Unknown Error',
|
||||||
|
desc: err.message
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unknown Mojang error.
|
// Unknown Mojang error.
|
||||||
@ -234,11 +241,11 @@ function loginCancelEnabled(val){
|
|||||||
|
|
||||||
loginCancelButton.onclick = (e) => {
|
loginCancelButton.onclick = (e) => {
|
||||||
switchView(getCurrentView(), loginViewOnCancel, 500, 500, () => {
|
switchView(getCurrentView(), loginViewOnCancel, 500, 500, () => {
|
||||||
|
loginUsername.value = ''
|
||||||
|
loginPassword.value = ''
|
||||||
loginCancelEnabled(false)
|
loginCancelEnabled(false)
|
||||||
if(loginViewCancelHandler != null){
|
if(loginViewCancelHandler != null){
|
||||||
loginViewCancelHandler()
|
loginViewCancelHandler()
|
||||||
loginUsername.value = ''
|
|
||||||
loginPassword.value = ''
|
|
||||||
loginViewCancelHandler = null
|
loginViewCancelHandler = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user