From 6d1ecd73ee038b55d83fa177c3e4ded87fce77bc Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Tue, 5 Feb 2019 17:26:00 -0500 Subject: [PATCH] Show a meaningful message if users try to login without a paid account. --- app/assets/js/authmanager.js | 15 ++++++++++----- app/assets/js/scripts/login.js | 19 +++++++++++++------ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/assets/js/authmanager.js b/app/assets/js/authmanager.js index 7d87d1a..22b2fed 100644 --- a/app/assets/js/authmanager.js +++ b/app/assets/js/authmanager.js @@ -29,12 +29,17 @@ const loggerSuccess = LoggerUtil('%c[AuthManager]', 'color: #209b07; font-weight exports.addAccount = async function(username, password){ try { const session = await Mojang.authenticate(username, password, ConfigManager.getClientToken()) - const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name) - if(ConfigManager.getClientToken() == null){ - ConfigManager.setClientToken(session.clientToken) + if(session.selectedProfile != null){ + const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name) + if(ConfigManager.getClientToken() == null){ + ConfigManager.setClientToken(session.clientToken) + } + ConfigManager.save() + return ret + } else { + throw new Error('NotPaidAccount') } - ConfigManager.save() - return ret + } catch (err){ return Promise.reject(err) } diff --git a/app/assets/js/scripts/login.js b/app/assets/js/scripts/login.js index 56f01df..67e7a58 100644 --- a/app/assets/js/scripts/login.js +++ b/app/assets/js/scripts/login.js @@ -206,10 +206,17 @@ function resolveError(err){ } } if(err.message != null){ - // Unknown error with request. - return { - title: 'Error During Login:
Unknown Error', - desc: err.message + if(err.message === 'NotPaidAccount'){ + return { + title: 'Error During Login:
Game Not Purchased', + desc: 'The account you are trying to login with has not purchased a copy of Minecraft.
You may purchase a copy on Minecraft.net' + } + } else { + // Unknown error with request. + return { + title: 'Error During Login:
Unknown Error', + desc: err.message + } } } else { // Unknown Mojang error. @@ -234,11 +241,11 @@ function loginCancelEnabled(val){ loginCancelButton.onclick = (e) => { switchView(getCurrentView(), loginViewOnCancel, 500, 500, () => { + loginUsername.value = '' + loginPassword.value = '' loginCancelEnabled(false) if(loginViewCancelHandler != null){ loginViewCancelHandler() - loginUsername.value = '' - loginPassword.value = '' loginViewCancelHandler = null } })