diff --git a/src/components/app/ByjoveApp.vue b/src/components/app/ByjoveApp.vue
index 0f0d061..3dbfe2f 100644
--- a/src/components/app/ByjoveApp.vue
+++ b/src/components/app/ByjoveApp.vue
@@ -43,6 +43,7 @@ export default {
// let all of app know who the user is(n't)
this.$store.commit('SET_USER', response.data.user)
+ this.$store.commit('SET_USER_IS_ADMIN', response.data.user ? response.data.user.is_admin : false)
this.$store.commit('SET_USER_IS_ROOT', response.data.user ? response.data.user.is_root : false)
// also keep track of user's permissions
diff --git a/src/components/menu/ByjoveMenu.vue b/src/components/menu/ByjoveMenu.vue
index 736602f..d4b1fbf 100644
--- a/src/components/menu/ByjoveMenu.vue
+++ b/src/components/menu/ByjoveMenu.vue
@@ -15,7 +15,7 @@
-
@@ -124,7 +124,7 @@ export default {
},
methods: {
becomeRoot() {
- if (this.user_is_root || !this.user.is_admin) {
+ if (this.user_is_root || !this.$store.state.user_is_admin) {
return
}
this.$http.post(this.becomeRootUrl).then(response => {
diff --git a/src/plugin.js b/src/plugin.js
index 2a42971..37d72aa 100644
--- a/src/plugin.js
+++ b/src/plugin.js
@@ -3,6 +3,23 @@ export function ByjovePlugin(Vue) {
Vue.mixin({
methods: {
+ $loginUser(user) {
+
+ // put user info in app store
+ this.$store.commit('SET_USER', user)
+ this.$store.commit('SET_USER_IS_ADMIN', user.is_admin)
+ // note, this should already be false
+ // this.$store.commit('SET_USER_IS_ROOT', false)
+ },
+
+ $logoutUser() {
+
+ // remove user info from app store
+ this.$store.commit('SET_USER', null)
+ this.$store.commit('SET_USER_IS_ADMIN', false)
+ this.$store.commit('SET_USER_IS_ROOT', false)
+ },
+
$hasPerm(name) {
// if user is root then assume permission
diff --git a/src/store.js b/src/store.js
index b1e13f9..4ddc273 100644
--- a/src/store.js
+++ b/src/store.js
@@ -3,6 +3,7 @@ export let ByjoveStoreConfig = {
state: {
session_established: false,
user: null,
+ user_is_admin: false,
user_is_root: false,
permissions: [],
},
@@ -13,6 +14,9 @@ export let ByjoveStoreConfig = {
SET_USER(state, user) {
state.user = user
},
+ SET_USER_IS_ADMIN(state, is_admin) {
+ state.user_is_admin = is_admin
+ },
SET_USER_IS_ROOT(state, is_root) {
state.user_is_root = is_root
},