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.
2020-10-15 11:29:56 -07:00
|
|
|
import Vue from 'vue';
|
2020-12-30 15:03:30 -08:00
|
|
|
import config from '../data/config.suml';
|
|
|
|
import {isGranted} from "../src/helpers";
|
2020-10-15 11:29:56 -07:00
|
|
|
|
2020-10-15 10:23:53 -07:00
|
|
|
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 09:50:32 -07:00
|
|
|
}
|
|
|
|
}
|
2020-10-15 11:29:56 -07:00
|
|
|
|
|
|
|
Vue.prototype.$user = _ => store.state.user;
|
2021-08-11 03:23:29 -07:00
|
|
|
Vue.prototype.$isGranted = (area = '') => {
|
2020-12-30 15:03:30 -08:00
|
|
|
return store.state.user && store.state.user.authenticated && isGranted(store.state.user, config.locale, area);
|
|
|
|
}
|
2020-10-15 09:50:32 -07:00
|
|
|
}
|