You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
willaengine/resources/js/Global/plugins/auth.js

27 lines
947 B

import { TokenService, PermissionService, UserService, CategoryNameService } from "@Global/services/storage.services";
import ApiService from "@Global/services/api.services";
import store from "@Core/store/index";
import Globalstore from "@Global/store/index";
ApiService.init();
// If token exists set Authorizion header
if (TokenService.getToken()) {
ApiService.setAuthHeader();
}
if (PermissionService.get()) {
store.commit('auth/SET_AUTH_PERMISSIONS', PermissionService.get())
5 years ago
} else if (TokenService.getToken() && UserService.get() && UserService.get().is_owner == 'false') {
store.dispatch('auth/loadAuthPermissions');
}
if (UserService.get()) {
store.commit('auth/SET_AUTH_USER', UserService.get())
5 years ago
}
if (CategoryNameService.get()) {
Globalstore.commit('common/SET_CATEGORY_NAME', CategoryNameService.get())
} else {
Globalstore.dispatch('common/loadCategoryName');
}
5 years ago
import '@Global/services/errorHandler.services'