This commit is contained in:
2018-11-13 21:59:51 +00:00
parent d14a8bb6c1
commit 86b2938879
7 changed files with 28 additions and 25 deletions

View File

@@ -32,7 +32,7 @@ export function processLogin(response) {
setToken(response.data.token);
//Put app relevant items into vuex store so app can use them
store.commit("authenticated", {
store.commit("setAuthentication", {
authenticated: true,
userId: Number(token.id),
roles: token["ayanova/roles"]
@@ -47,7 +47,7 @@ export function processLogin(response) {
export function processLogout() {
logger.log("Logout");
store.commit("notAuthenticated");
store.commit("clearAuthentication");
clearToken();
//router.go('/');
}

View File

@@ -5,7 +5,7 @@ import roles from "./roles";
import lt from "../api/locale";
function addNavItem(title, icon, route) {
store.state.navItems.push({
store.commit("addNavItem", {
title,
icon,
route
@@ -16,13 +16,11 @@ function addNavItem(title, icon, route) {
// Initialize the app
// on change of authentication status
export default function initialize() {
//clear the nav items either way
store.state.navItems = [];
//clear the locale text cache
lt.ClearCache();
lt.clearCache();
if (store.state.authenticated) {
//fetch the required localized text keys into the cache
lt.Fetch([
lt.fetch([
"Home",
"Service",
"Dispatch",
@@ -36,7 +34,7 @@ export default function initialize() {
.then(function() {
//put nav items into store
//Everyone has a home
addNavItem(lt.Get("Home"), "home", "/");
addNavItem(lt.get("Home"), "home", "/");
if (
roles.hasRole(roles.AuthorizationRoles.TechLimited) ||
@@ -44,26 +42,26 @@ export default function initialize() {
roles.hasRole(roles.AuthorizationRoles.SubContractorLimited) ||
roles.hasRole(roles.AuthorizationRoles.SubContractorFull)
) {
addNavItem(lt.Get("Service"), "toolbox", "/service");
addNavItem(lt.get("Service"), "toolbox", "/service");
}
if (
roles.hasRole(roles.AuthorizationRoles.DispatchLimited) ||
roles.hasRole(roles.AuthorizationRoles.DispatchFull)
) {
addNavItem(lt.Get("Dispatch"), "shipping-fast", "/dispatch");
addNavItem(lt.get("Dispatch"), "shipping-fast", "/dispatch");
}
if (
roles.hasRole(roles.AuthorizationRoles.InventoryLimited) ||
roles.hasRole(roles.AuthorizationRoles.InventoryFull)
) {
addNavItem(lt.Get("Inventory"), "dolly", "/inventory");
addNavItem(lt.get("Inventory"), "dolly", "/inventory");
}
if (roles.hasRole(roles.AuthorizationRoles.AccountingFull)) {
addNavItem(
lt.Get("Accounting"),
lt.get("Accounting"),
"file-invoice-dollar",
"/accounting"
);
@@ -73,19 +71,19 @@ export default function initialize() {
roles.hasRole(roles.AuthorizationRoles.BizAdminLimited) ||
roles.hasRole(roles.AuthorizationRoles.BizAdminFull)
) {
addNavItem(lt.Get("Administration"), "user-tie", "/admin");
addNavItem(lt.get("Administration"), "user-tie", "/admin");
}
if (
roles.hasRole(roles.AuthorizationRoles.OpsAdminFull) ||
roles.hasRole(roles.AuthorizationRoles.OpsAdminLimited)
) {
addNavItem(lt.Get("Operations"), "cogs", "ops");
addNavItem(lt.get("Operations"), "cogs", "ops");
}
//Everyone can see about and logout
addNavItem(lt.Get("HelpAboutAyaNova"), "info-circle", "/about");
addNavItem(lt.Get("Logout"), "sign-out-alt", "/login");
addNavItem(lt.get("HelpAboutAyaNova"), "info-circle", "/about");
addNavItem(lt.get("Logout"), "sign-out-alt", "/login");
})
.catch(function(error) {
logger.log("Initialize::() -> error", error);