Add session_established
flag in global store
This commit is contained in:
parent
777f877dd5
commit
a80a42fb56
src
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- note, we do not show anything at all until we have user info -->
|
<!-- note, we do not show anything at all until we have user info -->
|
||||||
<div class="main-container" v-show="fetchedUserInfo">
|
<div class="main-container" v-show="$store.state.session_established">
|
||||||
<slot>
|
<slot>
|
||||||
<p>TODO: put your nav in the default slot!</p>
|
<p>TODO: put your nav in the default slot!</p>
|
||||||
</slot>
|
</slot>
|
||||||
|
@ -28,12 +28,6 @@ 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
|
||||||
|
@ -54,27 +48,14 @@ export default {
|
||||||
// also keep track of user's permissions
|
// also keep track of user's permissions
|
||||||
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
|
// declare the session established
|
||||||
// TODO: remove this
|
this.$store.commit('SET_SESSION_ESTABLISHED', true)
|
||||||
if (!response.data.user && this.$route.name == 'logout') {
|
|
||||||
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?
|
// 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 () {
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
|
|
||||||
export let ByjoveStoreConfig = {
|
export let ByjoveStoreConfig = {
|
||||||
state: {
|
state: {
|
||||||
|
session_established: false,
|
||||||
user: null,
|
user: null,
|
||||||
user_is_root: null,
|
user_is_root: false,
|
||||||
permissions: [],
|
permissions: [],
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
SET_SESSION_ESTABLISHED(state, established) {
|
||||||
|
state.session_established = established
|
||||||
|
},
|
||||||
SET_USER(state, user) {
|
SET_USER(state, user) {
|
||||||
state.user = user
|
state.user = user
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue