Delay showing the app until user info is fetched

This commit is contained in:
Lance Edgar 2020-02-10 19:53:36 -06:00
parent 5451f87f30
commit 7664f9bbb9

View file

@ -1,5 +1,6 @@
<template>
<div class="main-container">
<!-- note, we do not show anything at all until we have user info -->
<div class="main-container" v-show="fetchedUserInfo">
<slot>
<p>TODO: put your nav in the default slot!</p>
</slot>
@ -27,6 +28,12 @@ export default {
default: true,
},
},
data() {
return {
// we will not display anything until we have user info
'fetchedUserInfo': false,
}
},
beforeCreate: function() {
// TODO: even with beforeCreate() this logic is still happening "too
@ -48,14 +55,26 @@ export default {
this.$store.commit('SET_PERMISSIONS', response.data.permissions)
// if user is anonymous, and requested logout page, send to login instead
// TODO: remove this
if (!response.data.user && this.$route.name == 'logout') {
this.$router.push('/login')
}
// set background color, to whatever api said
// TODO: should this be the custom app's responsibility?
if (response.data.background_color) {
document.body.style.backgroundColor = response.data.background_color
}
// okay now we can let the app display. if this page needs to
// redirect based on new info, that should have happened by now?
this.fetchedUserInfo = true
}, response => { // error handler
// pretend that we *did* get user info, just so something displays
// TODO: should probably show some kind of warning also
this.fetchedUserInfo = true
})
},
mounted: function () {