export function ByjovePlugin(Vue) { Vue.mixin({ methods: { $loginUser(user, permissions) { // 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) // maybe update permissions if (permissions !== undefined) { this.$store.commit('SET_PERMISSIONS', permissions) } }, $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 if (this.$store.state.user_is_root) { return true } // otherwise do true perm check for user return this.$store.state.permissions.includes(name) }, } }) Vue.filter('byjoveCurrency', function (value) { if (typeof value !== 'number') { return value } var formatter = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', // TODO: make this configurable? minimumFractionDigits: 2, }) return formatter.format(value) }) }