Delay showing the app until user info is fetched
This commit is contained in:
parent
5451f87f30
commit
7664f9bbb9
1 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<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>
|
<slot>
|
||||||
<p>TODO: put your nav in the default slot!</p>
|
<p>TODO: put your nav in the default slot!</p>
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -27,6 +28,12 @@ export default {
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// we will not display anything until we have user info
|
||||||
|
'fetchedUserInfo': false,
|
||||||
|
}
|
||||||
|
},
|
||||||
beforeCreate: function() {
|
beforeCreate: function() {
|
||||||
|
|
||||||
// TODO: even with beforeCreate() this logic is still happening "too
|
// TODO: even with beforeCreate() this logic is still happening "too
|
||||||
|
@ -48,14 +55,26 @@ export default {
|
||||||
this.$store.commit('SET_PERMISSIONS', response.data.permissions)
|
this.$store.commit('SET_PERMISSIONS', response.data.permissions)
|
||||||
|
|
||||||
// if user is anonymous, and requested logout page, send to login instead
|
// if user is anonymous, and requested logout page, send to login instead
|
||||||
|
// TODO: remove this
|
||||||
if (!response.data.user && this.$route.name == 'logout') {
|
if (!response.data.user && this.$route.name == 'logout') {
|
||||||
this.$router.push('/login')
|
this.$router.push('/login')
|
||||||
}
|
}
|
||||||
|
|
||||||
// set background color, to whatever api said
|
// set background color, to whatever api said
|
||||||
|
// TODO: should this be the custom app's responsibility?
|
||||||
if (response.data.background_color) {
|
if (response.data.background_color) {
|
||||||
document.body.style.backgroundColor = 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 () {
|
mounted: function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue