admin_users_personels
This commit is contained in:
53
frontend_admin/.nuxt/dist/server/_nuxt/auth-Cq1Vc_k9.js
vendored
Normal file
53
frontend_admin/.nuxt/dist/server/_nuxt/auth-Cq1Vc_k9.js
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
import { executeAsync } from "/app/node_modules/unctx/dist/index.mjs";
|
||||
import { e as defineNuxtRouteMiddleware, d as useCookie, n as navigateTo, c as useAuthStore } from "../server.mjs";
|
||||
import "vue";
|
||||
import "/app/node_modules/ofetch/dist/node.mjs";
|
||||
import "#internal/nuxt/paths";
|
||||
import "/app/node_modules/hookable/dist/index.mjs";
|
||||
import "/app/node_modules/h3/dist/index.mjs";
|
||||
import "pinia";
|
||||
import "/app/node_modules/defu/dist/defu.mjs";
|
||||
import "vue-router";
|
||||
import "/app/node_modules/ufo/dist/index.mjs";
|
||||
import "/app/node_modules/klona/dist/index.mjs";
|
||||
import "/app/node_modules/cookie-es/dist/index.mjs";
|
||||
import "/app/node_modules/destr/dist/index.mjs";
|
||||
import "/app/node_modules/ohash/dist/index.mjs";
|
||||
import "/app/node_modules/@unhead/vue/dist/index.mjs";
|
||||
import "@vue/devtools-api";
|
||||
import "vue/server-renderer";
|
||||
const auth = defineNuxtRouteMiddleware(async (to, from) => {
|
||||
let __temp, __restore;
|
||||
if (to.path === "/login") {
|
||||
return;
|
||||
}
|
||||
const tokenCookie = useCookie("access_token");
|
||||
if (!tokenCookie.value) {
|
||||
return navigateTo("/login");
|
||||
}
|
||||
const authStore = useAuthStore();
|
||||
if (!authStore.user) {
|
||||
try {
|
||||
;
|
||||
[__temp, __restore] = executeAsync(() => authStore.fetchUser()), await __temp, __restore();
|
||||
;
|
||||
} catch {
|
||||
authStore.logout();
|
||||
return navigateTo("/login");
|
||||
}
|
||||
}
|
||||
if (!authStore.user) {
|
||||
authStore.logout();
|
||||
return navigateTo("/login");
|
||||
}
|
||||
const allowedRoles = ["SUPERADMIN", "ADMIN", "MODERATOR", "SALES_REP", "SERVICE_MGR"];
|
||||
const userRole = (authStore.user.role || "").toUpperCase();
|
||||
if (!allowedRoles.includes(userRole)) {
|
||||
authStore.logout();
|
||||
return navigateTo("/login");
|
||||
}
|
||||
});
|
||||
export {
|
||||
auth as default
|
||||
};
|
||||
//# sourceMappingURL=auth-Cq1Vc_k9.js.map
|
||||
Reference in New Issue
Block a user