v0.0.1-alpha.6

Fixed AuthManager sending incorrect client token to the auth endpoint.
Fixed minor issues with the validate selected function.
Fixed minor issue related to UI transitions.
Added account validations on startup and when account is switched.
Updated dependencies.
This commit is contained in:
Daniel Scalzi 2018-05-29 21:47:55 -04:00
parent 5a692d9088
commit daa6faac86
No known key found for this signature in database
GPG Key ID: 5CA2F145B63535F9
7 changed files with 162 additions and 68 deletions

View File

@ -25,7 +25,7 @@ const Mojang = require('./mojang.js')
*/ */
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) const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name)
ConfigManager.save() ConfigManager.save()
return ret return ret

View File

@ -236,6 +236,8 @@ loginButton.addEventListener('click', () => {
switchView(VIEWS.login, VIEWS.landing, 500, 500, () => { switchView(VIEWS.login, VIEWS.landing, 500, 500, () => {
loginUsername.value = '' loginUsername.value = ''
loginPassword.value = '' loginPassword.value = ''
$('.circle-loader').toggleClass('load-complete')
$('.checkmark').toggle()
loginLoading(false) loginLoading(false)
loginButton.innerHTML = loginButton.innerHTML.replace('SUCCESS', 'LOGIN') loginButton.innerHTML = loginButton.innerHTML.replace('SUCCESS', 'LOGIN')
formDisabled(false) formDisabled(false)

View File

@ -248,12 +248,8 @@ function populateServerListings(){
function populateAccountListings(){ function populateAccountListings(){
const accountsObj = ConfigManager.getAuthAccounts() const accountsObj = ConfigManager.getAuthAccounts()
const accounts = Array.from(Object.keys(accountsObj), v=>accountsObj[v]); const accounts = Array.from(Object.keys(accountsObj), v=>accountsObj[v]);
const selectedUUID = ConfigManager.getSelectedAccount().uuid
let htmlString = `` let htmlString = ``
for(let i=0; i<accounts.length; i++){ for(let i=0; i<accounts.length; i++){
if(accounts[i].uuid === selectedUUID) {
continue
}
htmlString += `<button class="accountListing" uuid="${accounts[i].uuid}" ${i===0 ? 'selected' : ''}> htmlString += `<button class="accountListing" uuid="${accounts[i].uuid}" ${i===0 ? 'selected' : ''}>
<img src="https://crafatar.com/renders/head/${accounts[i].uuid}?scale=2&default=MHF_Steve&overlay"> <img src="https://crafatar.com/renders/head/${accounts[i].uuid}?scale=2&default=MHF_Steve&overlay">
<div class="accountListingName">${accounts[i].displayName}</div> <div class="accountListingName">${accounts[i].displayName}</div>

View File

@ -13,10 +13,10 @@ let fatalStartupError = false
// Mapping of each view to their container IDs. // Mapping of each view to their container IDs.
const VIEWS = { const VIEWS = {
landing: 'landingContainer', landing: '#landingContainer',
login: 'loginContainer', login: '#loginContainer',
settings: 'settingsContainer', settings: '#settingsContainer',
welcome: 'welcomeContainer' welcome: '#welcomeContainer'
} }
// The currently shown view container. // The currently shown view container.
@ -35,10 +35,10 @@ let currentView = VIEWS.landing
* fades in. * fades in.
*/ */
function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, onCurrentFade = () => {}, onNextFade = () => {}){ function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, onCurrentFade = () => {}, onNextFade = () => {}){
currentView = current currentView = next
$(`#${current}`).fadeOut(currentFadeTime, () => { $(`${current}`).fadeOut(currentFadeTime, () => {
onCurrentFade() onCurrentFade()
$(`#${next}`).fadeIn(nextFadeTime, () => { $(`${next}`).fadeIn(nextFadeTime, () => {
onNextFade() onNextFade()
}) })
}) })
@ -61,12 +61,22 @@ function showMainUI(){
document.body.style.backgroundImage = `url('assets/images/backgrounds/${document.body.getAttribute('bkid')}.jpg')` document.body.style.backgroundImage = `url('assets/images/backgrounds/${document.body.getAttribute('bkid')}.jpg')`
$('#main').show() $('#main').show()
//validateSelectedAccount() // If this is enabled in a development environment we'll get ratelimited.
// The relaunch frequency is usually far too high.
if(!isDev){
validateSelectedAccount().then((v) => {
if(v){
console.log('%c[AuthManager]', 'color: #209b07; font-weight: bold', 'Account access token validated.')
} else {
console.log('%c[AuthManager]', 'color: #a02d2a; font-weight: bold', 'Account access token is invalid.')
}
})
}
if(ConfigManager.isFirstLaunch()){ if(ConfigManager.isFirstLaunch()){
$('#welcomeContainer').fadeIn(1000) $(VIEWS.welcome).fadeIn(1000)
} else { } else {
$('#landingContainer').fadeIn(1000) $(VIEWS.landing).fadeIn(1000)
} }
setTimeout(() => { setTimeout(() => {
@ -123,10 +133,12 @@ async function validateSelectedAccount(){
if(selectedAcc != null){ if(selectedAcc != null){
const val = await AuthManager.validateSelected() const val = await AuthManager.validateSelected()
if(!val){ if(!val){
ConfigManager.removeAuthAccount(selectedAcc.uuid)
ConfigManager.save()
const accLen = Object.keys(ConfigManager.getAuthAccounts()).length const accLen = Object.keys(ConfigManager.getAuthAccounts()).length
setOverlayContent( setOverlayContent(
'Failed to Refresh Login', 'Failed to Refresh Login',
`We were unable to refresh the login for <strong>${selectedAcc.displayName}</strong>. Please ${accLen > 1 ? 'select another account or ' : ''} login again.`, `We were unable to refresh the login for <strong>${selectedAcc.displayName}</strong>. Please ${accLen > 0 ? 'select another account or ' : ''} login again.`,
'Login', 'Login',
'Select Another Account' 'Select Another Account'
) )
@ -137,25 +149,20 @@ async function validateSelectedAccount(){
toggleOverlay(false) toggleOverlay(false)
}) })
setDismissHandler(() => { setDismissHandler(() => {
if(accLen > 2){ if(accLen > 1){
prepareAccountSelectionList() prepareAccountSelectionList()
$('#overlayContent').fadeOut(250, () => { $('#overlayContent').fadeOut(250, () => {
$('#accountSelectContent').fadeIn(250) $('#accountSelectContent').fadeIn(250)
}) })
} else { } else {
const accountsObj = ConfigManager.getAuthAccounts() const accountsObj = ConfigManager.getAuthAccounts()
const accounts = Array.from(Object.keys(accountsObj), v=>accountsObj[v]); const accounts = Array.from(Object.keys(accountsObj), v => accountsObj[v]);
const selectedUUID = ConfigManager.getSelectedAccount().uuid // This function validates the account switch.
for(let i=0; i<accounts.length; i++){ setSelectedAccount(accounts[0].uuid)
if(accounts[i].uuid !== selectedUUID){
setSelectedAccount(accounts[i].uuid)
toggleOverlay(false) toggleOverlay(false)
validateSelectedAccount()
}
}
} }
}) })
toggleOverlay(true, accLen > 1) toggleOverlay(true, accLen > 0)
} else { } else {
return true return true
} }
@ -174,7 +181,7 @@ function setSelectedAccount(uuid){
const authAcc = ConfigManager.setSelectedAccount(uuid) const authAcc = ConfigManager.setSelectedAccount(uuid)
ConfigManager.save() ConfigManager.save()
updateSelectedAccount(authAcc) updateSelectedAccount(authAcc)
//validateSelectedAccount() validateSelectedAccount()
} }
// Synchronous Listener // Synchronous Listener

View File

@ -56,14 +56,4 @@
</form> </form>
</div> </div>
<script src="./assets/js/scripts/login.js"></script> <script src="./assets/js/scripts/login.js"></script>
<!-- Will reuse this down the line, then it will be removed from this file. -->
<!--<div id="loginLoading">
<div id="loginLoadingContent">
<div id="loadSpinnerContainer">
<img id="loadCenterImage" src="assets/images/westeroscraftlogo1.png">
<img id="loadSpinnerImage" class="rotating" src="assets/images/westeroscraftlogo2.png">
</div>
<span id="loadDescText">LOGGING IN</span>
</div>
</div>-->
</div> </div>

155
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "westeroscraftlauncher", "name": "westeroscraftlauncher",
"version": "0.0.1-alpha.5", "version": "0.0.1-alpha.6",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -96,9 +96,9 @@
} }
}, },
"app-builder-bin": { "app-builder-bin": {
"version": "1.9.5", "version": "1.9.11",
"resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-1.9.5.tgz", "resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-1.9.11.tgz",
"integrity": "sha512-Uw8jhfww5gYcAvMVgeRZ9cdlXOv+Ivqy4LSbALPMrQrCHHTmfVXETthkhW3cQKdvDo9pRuYn+Q5egSSn04F+Wg==", "integrity": "sha512-GeB00tbuMeRa5NfYpKAnE3m2Ztj5QKa8pdrYKkg2CxZgyQn3iqJEUzy1EWMS6O1a1pX8wJxPLkEzUghg43bXWQ==",
"dev": true "dev": true
}, },
"argparse": { "argparse": {
@ -318,13 +318,13 @@
"integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==" "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA=="
}, },
"builder-util": { "builder-util": {
"version": "5.11.1", "version": "5.11.4",
"resolved": "https://registry.npmjs.org/builder-util/-/builder-util-5.11.1.tgz", "resolved": "https://registry.npmjs.org/builder-util/-/builder-util-5.11.4.tgz",
"integrity": "sha512-fZu9j33B4VMeUJaeb1q2TubKWrk9tAg2Jwpgjstxk7Mu7sNw7v/XB87/EbpNBlE3RPMrXblG6f8asfCRC8IiNQ==", "integrity": "sha512-H6KnYwoeA9tEDz0EQNqridZ5YuJiyCX61TyhOMZmLiMnfJCuVfpyXbfYKUDMTAP8vmvjiAYJhbU8THkiHpKljA==",
"dev": true, "dev": true,
"requires": { "requires": {
"7zip-bin": "~4.0.2", "7zip-bin": "~4.0.2",
"app-builder-bin": "1.9.5", "app-builder-bin": "1.9.11",
"bluebird-lst": "^1.0.5", "bluebird-lst": "^1.0.5",
"builder-util-runtime": "^4.2.1", "builder-util-runtime": "^4.2.1",
"chalk": "^2.4.1", "chalk": "^2.4.1",
@ -725,6 +725,90 @@
"js-yaml": "^3.11.0", "js-yaml": "^3.11.0",
"parse-color": "^1.0.0", "parse-color": "^1.0.0",
"sanitize-filename": "^1.6.1" "sanitize-filename": "^1.6.1"
},
"dependencies": {
"app-builder-bin": {
"version": "1.9.5",
"resolved": "https://registry.npmjs.org/app-builder-bin/-/app-builder-bin-1.9.5.tgz",
"integrity": "sha512-Uw8jhfww5gYcAvMVgeRZ9cdlXOv+Ivqy4LSbALPMrQrCHHTmfVXETthkhW3cQKdvDo9pRuYn+Q5egSSn04F+Wg==",
"dev": true
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"electron-builder-lib": {
"version": "20.14.7",
"resolved": "https://registry.npmjs.org/electron-builder-lib/-/electron-builder-lib-20.14.7.tgz",
"integrity": "sha512-sPlpRN5Nea9ZK+nwZcD5ZuGoK2uCj2muQ7enc+9BeXPAxnEu4yYmYanICAi4BQqUdusm4yjjnN9uPowlbvCNzA==",
"dev": true,
"requires": {
"7zip-bin": "~4.0.2",
"app-builder-bin": "1.9.5",
"async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.5",
"builder-util": "5.11.1",
"builder-util-runtime": "4.2.1",
"chromium-pickle-js": "^0.2.0",
"debug": "^3.1.0",
"ejs": "^2.6.1",
"electron-osx-sign": "0.4.10",
"electron-publish": "20.14.6",
"fs-extra-p": "^4.6.0",
"hosted-git-info": "^2.6.0",
"is-ci": "^1.1.0",
"isbinaryfile": "^3.0.2",
"js-yaml": "^3.11.0",
"lazy-val": "^1.0.3",
"minimatch": "^3.0.4",
"normalize-package-data": "^2.4.0",
"plist": "^3.0.1",
"read-config-file": "3.0.1",
"sanitize-filename": "^1.6.1",
"semver": "^5.5.0",
"stream-json": "^0.6.1",
"temp-file": "^3.1.2"
},
"dependencies": {
"builder-util": {
"version": "5.11.1",
"resolved": "https://registry.npmjs.org/builder-util/-/builder-util-5.11.1.tgz",
"integrity": "sha512-fZu9j33B4VMeUJaeb1q2TubKWrk9tAg2Jwpgjstxk7Mu7sNw7v/XB87/EbpNBlE3RPMrXblG6f8asfCRC8IiNQ==",
"dev": true,
"requires": {
"7zip-bin": "~4.0.2",
"app-builder-bin": "1.9.5",
"bluebird-lst": "^1.0.5",
"builder-util-runtime": "^4.2.1",
"chalk": "^2.4.1",
"debug": "^3.1.0",
"fs-extra-p": "^4.6.0",
"is-ci": "^1.1.0",
"js-yaml": "^3.11.0",
"lazy-val": "^1.0.3",
"semver": "^5.5.0",
"source-map-support": "^0.5.6",
"stat-mode": "^0.2.2",
"temp-file": "^3.1.2"
}
}
}
},
"source-map-support": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.6.tgz",
"integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
}
} }
}, },
"dot-prop": { "dot-prop": {
@ -789,17 +873,17 @@
} }
}, },
"electron-builder": { "electron-builder": {
"version": "20.14.7", "version": "20.15.3",
"resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-20.14.7.tgz", "resolved": "https://registry.npmjs.org/electron-builder/-/electron-builder-20.15.3.tgz",
"integrity": "sha512-f6k0hDmMof3tKn/RqNMfgNYdSl/UNomFTFw7pizbj8v33iVwCqST02Iqo/xpuXWi0KrJNdBlJvbva1DU/vkYkg==", "integrity": "sha512-hoZN5+2aFSMH60otpzxYqJAOCxWXdYpLm5c/pMSSyK91LACd0UyLx9IMpFXZadavmHTgf5z/94Blf3/+/2LRgw==",
"dev": true, "dev": true,
"requires": { "requires": {
"bluebird-lst": "^1.0.5", "bluebird-lst": "^1.0.5",
"builder-util": "5.11.1", "builder-util": "5.11.4",
"builder-util-runtime": "4.2.1", "builder-util-runtime": "4.2.1",
"chalk": "^2.4.1", "chalk": "^2.4.1",
"dmg-builder": "4.10.1", "dmg-builder": "4.10.1",
"electron-builder-lib": "20.14.7", "electron-builder-lib": "20.15.3",
"electron-download-tf": "4.3.4", "electron-download-tf": "4.3.4",
"fs-extra-p": "^4.6.0", "fs-extra-p": "^4.6.0",
"is-ci": "^1.1.0", "is-ci": "^1.1.0",
@ -885,22 +969,22 @@
} }
}, },
"electron-builder-lib": { "electron-builder-lib": {
"version": "20.14.7", "version": "20.15.3",
"resolved": "https://registry.npmjs.org/electron-builder-lib/-/electron-builder-lib-20.14.7.tgz", "resolved": "https://registry.npmjs.org/electron-builder-lib/-/electron-builder-lib-20.15.3.tgz",
"integrity": "sha512-sPlpRN5Nea9ZK+nwZcD5ZuGoK2uCj2muQ7enc+9BeXPAxnEu4yYmYanICAi4BQqUdusm4yjjnN9uPowlbvCNzA==", "integrity": "sha512-qOp0zwXCNICEk9IrRR8Q0sTTPvwjQDO2nWzJ/7lMYg7b71GVfF1I3d2IjMgEmrhPzWsF9XAFIWyPduN1aRLYgA==",
"dev": true, "dev": true,
"requires": { "requires": {
"7zip-bin": "~4.0.2", "7zip-bin": "~4.0.2",
"app-builder-bin": "1.9.5", "app-builder-bin": "1.9.11",
"async-exit-hook": "^2.0.1", "async-exit-hook": "^2.0.1",
"bluebird-lst": "^1.0.5", "bluebird-lst": "^1.0.5",
"builder-util": "5.11.1", "builder-util": "5.11.4",
"builder-util-runtime": "4.2.1", "builder-util-runtime": "4.2.1",
"chromium-pickle-js": "^0.2.0", "chromium-pickle-js": "^0.2.0",
"debug": "^3.1.0", "debug": "^3.1.0",
"ejs": "^2.6.1", "ejs": "^2.6.1",
"electron-osx-sign": "0.4.10", "electron-osx-sign": "0.4.10",
"electron-publish": "20.14.6", "electron-publish": "20.15.0",
"fs-extra-p": "^4.6.0", "fs-extra-p": "^4.6.0",
"hosted-git-info": "^2.6.0", "hosted-git-info": "^2.6.0",
"is-ci": "^1.1.0", "is-ci": "^1.1.0",
@ -925,6 +1009,21 @@
"requires": { "requires": {
"ms": "2.0.0" "ms": "2.0.0"
} }
},
"electron-publish": {
"version": "20.15.0",
"resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-20.15.0.tgz",
"integrity": "sha512-0v1jXvbRDlPK5S+LzEZqcvuFHLCSWPKmMYmbDwVheeNRjbJjQLlZyQAINVlV+Ky+yhawChEaAF+dyGLvXEyONg==",
"dev": true,
"requires": {
"bluebird-lst": "^1.0.5",
"builder-util": "^5.11.2",
"builder-util-runtime": "^4.2.1",
"chalk": "^2.4.1",
"fs-extra-p": "^4.6.0",
"lazy-val": "^1.0.3",
"mime": "^2.3.1"
}
} }
} }
}, },
@ -2720,18 +2819,18 @@
} }
}, },
"uri-js": { "uri-js": {
"version": "4.2.1", "version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.1.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-jpKCA3HjsBfSDOEgxRDAxQCNyHfCPSbq57PqCkd3gAyBuPb3IWxw54EHncqESznIdqSetHfw3D7ylThu2Kcc9A==", "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"punycode": "^2.1.0" "punycode": "^2.1.0"
}, },
"dependencies": { "dependencies": {
"punycode": { "punycode": {
"version": "2.1.0", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
"integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true "dev": true
} }
} }
@ -2782,9 +2881,9 @@
} }
}, },
"which": { "which": {
"version": "1.3.0", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"isexe": "^2.0.0" "isexe": "^2.0.0"

View File

@ -1,6 +1,6 @@
{ {
"name": "westeroscraftlauncher", "name": "westeroscraftlauncher",
"version": "0.0.1-alpha.5", "version": "0.0.1-alpha.6",
"description": "Custom modded launcher for Westeroscraft", "description": "Custom modded launcher for Westeroscraft",
"productName": "WesterosCraft Launcher", "productName": "WesterosCraft Launcher",
"main": "index.js", "main": "index.js",
@ -45,7 +45,7 @@
}, },
"devDependencies": { "devDependencies": {
"electron": "^2.0.2", "electron": "^2.0.2",
"electron-builder": "^20.14.7" "electron-builder": "^20.15.3"
}, },
"build": { "build": {
"appId": "westeroscraftlauncher", "appId": "westeroscraftlauncher",