This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/plugins/auth.js

18 lines
483 B
JavaScript
Raw Normal View History

2020-10-15 11:29:56 -07:00
import Vue from 'vue';
import t from "../src/translator";
export default ({app, store}) => {
const token = app.$cookies.get('token');
if (token) {
store.commit('setToken', token);
if (!store.state.token) {
app.$cookies.removeAll();
}
}
2020-10-15 11:29:56 -07:00
Vue.prototype.$user = _ => store.state.user;
2020-10-15 11:55:24 -07:00
Vue.prototype.$admin = _ => {
return store.state.user && store.state.user.authenticated && store.state.user.roles === 'admin';
};
}