2020-02-11 11:05:31 -06:00
|
|
|
|
|
|
|
|
export function ByjovePlugin(Vue) {
|
|
|
|
|
Vue.mixin({
|
|
|
|
|
methods: {
|
|
|
|
|
|
2020-02-11 13:33:54 -06:00
|
|
|
$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)
|
|
|
|
|
},
|
|
|
|
|
|
2020-02-11 11:05:31 -06:00
|
|
|
$hasPerm(name) {
|
|
|
|
|
|
|
|
|
|
// if user is root then assume permission
|
|
|
|
|
if (this.$store.state.user_is_root) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// otherwise do true perm check for user
|
|
|
|
|
return this.$store.state.permissions.includes(name)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|