admin felület bekötése. pontosítások2

This commit is contained in:
Roo
2026-06-27 09:08:18 +00:00
parent c75c7b2270
commit 1e6f79ca22
189 changed files with 4624 additions and 1116 deletions

View File

@@ -1,7 +1,7 @@
import process from 'node:process';globalThis._importMeta_=globalThis._importMeta_||{url:"file:///_entry.js",env:process.env};import * as Vue from 'vue';
import { getCurrentScope, onScopeDispose, ref, inject, computed, hasInjectionContext, getCurrentInstance as getCurrentInstance$1, shallowRef, defineComponent, createElementBlock, provide, cloneVNode, h, defineAsyncComponent, unref, shallowReactive, Suspense, Fragment, useSSRContext, createApp, createVNode, Text, withCtx, onErrorCaptured, onServerPrefetch, resolveDynamicComponent, reactive, effectScope, nextTick, mergeProps, toRef, isReadonly, toRaw, isRef, isShallow, isReactive } from 'vue';
import { ref, computed, getCurrentScope, onScopeDispose, inject, hasInjectionContext, getCurrentInstance as getCurrentInstance$1, shallowRef, defineComponent, createElementBlock, provide, cloneVNode, h, defineAsyncComponent, unref, shallowReactive, Suspense, Fragment, useSSRContext, createApp, createVNode, Text, withCtx, onErrorCaptured, onServerPrefetch, resolveDynamicComponent, reactive, effectScope, nextTick, mergeProps, toRef, isReadonly, toRaw, isRef, isShallow, isReactive } from 'vue';
import { q as klona, r as parseURL, e as encodePath, s as decodePath, t as hasProtocol, v as isScriptProtocol, w as joinURL, x as withQuery, y as parse$1, z as getRequestHeader, A as destr, B as isEqual, C as sanitizeStatusCode, D as setCookie, E as getCookie, F as deleteCookie, G as getContext, $ as $fetch$1, H as baseURL, I as defu, J as createHooks, j as createError$1, K as executeAsync, L as getRequestURL, M as createDefu, N as parsePath, O as parseQuery, P as withoutTrailingSlash } from '../nitro/nitro.mjs';
import { setActivePinia, createPinia, shouldHydrate } from 'pinia';
import { defineStore, setActivePinia, createPinia, shouldHydrate } from 'pinia';
import { useRoute as useRoute$1, RouterView, createMemoryHistory, createRouter, START_LOCATION } from 'vue-router';
import { ssrRenderComponent, ssrRenderSuspense, ssrRenderVNode } from 'vue/server-renderer';
import { u as useHead$1, h as headSymbol } from '../routes/renderer.mjs';
@@ -473,13 +473,13 @@ const _routes = [
name: "login",
path: "/login",
meta: __nuxt_page_meta || {},
component: () => import('./login-Dx4mHuUH.mjs')
component: () => import('./login-DOiXgKDi.mjs')
},
{
name: "garages",
path: "/garages",
meta: { "middleware": "auth" },
component: () => import('./index-o-V5Lz0_.mjs')
component: () => import('./index-CzKBE-M2.mjs')
},
{
name: "packages",
@@ -491,13 +491,12 @@ const _routes = [
name: "permissions",
path: "/permissions",
meta: { "middleware": "auth" },
component: () => import('./index-D2n0yf-2.mjs')
component: () => import('./index-DgwDY6Ie.mjs')
},
{
name: "garages-id",
path: "/garages/:id()",
meta: { "middleware": "auth" },
component: () => import('./index-JpXwtL-Z.mjs')
component: () => import('./index-1I7UC9HP.mjs')
}
];
const _wrapInTransition = (props, children) => {
@@ -642,7 +641,7 @@ const globalMiddleware = [
manifest_45route_45rule
];
const namedMiddleware = {
auth: () => import('./auth-9ekP0oPk.mjs')
auth: () => import('./auth-B3jrOAhu.mjs')
};
Object.assign(/* @__PURE__ */ Object.create(null), {});
const pageIslandRoutes = Object.assign(/* @__PURE__ */ Object.create(null), {});
@@ -1427,7 +1426,7 @@ const localeLoaders = {
{
key: "locale_hu_46json_ee06c965",
load: () => import(
'./hu-B3JxlqZo.mjs'
'./hu-Ck1VzT5S.mjs'
/* webpackChunkName: "locale_hu_46json_ee06c965" */
),
cache: true
@@ -1437,7 +1436,7 @@ const localeLoaders = {
{
key: "locale_en_46json_0b63539c",
load: () => import(
'./en-WIj2pBfh.mjs'
'./en-BI6r-iRW.mjs'
/* webpackChunkName: "locale_en_46json_0b63539c" */
),
cache: true
@@ -1577,7 +1576,7 @@ function getDefaultLocaleForDomain(host) {
}
const isSupportedLocale = (locale) => localeCodes.includes(locale || "");
const resolveSupportedLocale = (locale) => isSupportedLocale(locale) ? locale : void 0;
var define_I18N_LOCALE_HASHES_default$1 = { hu: "bb1d6803", en: "bb1d6803" };
var define_I18N_LOCALE_HASHES_default$1 = { hu: "4ec99847", en: "4ec99847" };
const useLocaleConfigs = () => useState(
"i18n:cached-locale-configs",
() => void 0
@@ -5907,7 +5906,7 @@ const setupVueI18nOptions = async (defaultLocale) => {
}
return options;
};
var define_I18N_LOCALE_HASHES_default = { hu: "bb1d6803", en: "bb1d6803" };
var define_I18N_LOCALE_HASHES_default = { hu: "4ec99847", en: "4ec99847" };
const i18n_EI7LsD1KYQADczz5hrChviGQCdVM8yUkvFEZLJpmnvM = /* @__PURE__ */ defineNuxtPlugin({
name: "i18n:plugin",
parallel: false,
@@ -5990,6 +5989,138 @@ const i18n_EI7LsD1KYQADczz5hrChviGQCdVM8yUkvFEZLJpmnvM = /* @__PURE__ */ defineN
nuxt.provide("switchLocalePath", useSwitchLocalePath(nuxt));
}
});
const useAuthStore = defineStore("auth", () => {
const user = ref(null);
const token = ref(null);
const isLoading = ref(false);
const error = ref(null);
const isInitialized = ref(false);
const isAuthenticated = computed(() => !!token.value && !!user.value);
const isAdmin = computed(() => {
const role = user.value?.role;
if (!role) return false;
const staffRoles = ["SUPERADMIN", "ADMIN", "MODERATOR", "SALES_REP", "SERVICE_MGR"];
return staffRoles.includes(role.toUpperCase());
});
const userName = computed(() => {
if (!user.value) return "";
const { first_name, last_name } = user.value;
if (first_name && last_name) return `${first_name} ${last_name}`;
return first_name || last_name || user.value.email;
});
const userEmail = computed(() => user.value?.email ?? "");
const userRole = computed(() => user.value?.role ?? "guest");
async function login(email, password) {
isLoading.value = true;
error.value = null;
try {
const body = new URLSearchParams();
body.append("username", email);
body.append("password", password);
const res = await $fetch("/api/v1/auth/login", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body
});
const tokenCookie = useCookie("access_token", {
maxAge: 60 * 60 * 24 * 7,
// 7 days
path: "/",
sameSite: "lax",
secure: true
});
tokenCookie.value = res.access_token;
token.value = res.access_token;
await fetchUser();
} catch (err) {
error.value = err?.data?.detail || err?.message || "Login failed";
throw err;
} finally {
isLoading.value = false;
}
}
async function fetchUser() {
const tokenCookie = useCookie("access_token");
const currentToken = tokenCookie.value || token.value;
if (!currentToken) return;
try {
const res = await $fetch("/api/v1/auth/me", {
headers: { Authorization: `Bearer ${currentToken}` }
});
user.value = res;
} catch (err) {
if (err?.response?.status === 401) {
logout();
}
throw err;
}
}
function logout() {
token.value = null;
user.value = null;
error.value = null;
const tokenCookie = useCookie("access_token");
tokenCookie.value = null;
}
async function init() {
const tokenCookie = useCookie("access_token");
if (tokenCookie.value) {
token.value = tokenCookie.value;
try {
await fetchUser();
} catch {
logout();
}
}
isInitialized.value = true;
}
function clearError() {
error.value = null;
}
return {
// State
user,
token,
isLoading,
error,
isInitialized,
// Getters
isAuthenticated,
isAdmin,
userName,
userEmail,
userRole,
// Actions
login,
fetchUser,
logout,
init,
clearError
};
});
const api_jy9dy79pM_nYQuRKPrcfNg56p_gKkzw9SekUTZgAenc = /* @__PURE__ */ defineNuxtPlugin(() => {
const originalFetch = globalThis.fetch;
globalThis.fetch = async (input, init) => {
const response = await originalFetch(input, init);
if (response.status === 401) {
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
if (url.includes("/auth/login") || url.includes("/auth/refresh")) {
return response;
}
try {
const authStore = useAuthStore();
authStore.logout();
} catch {
const tokenCookie = useCookie("access_token");
tokenCookie.value = null;
}
{
await navigateTo("/login");
}
}
return response;
};
});
const ssg_detect_IpHCGcQQ_IR5Rl99qyukWoMA9fJGfuTYyoksTzy81cs = /* @__PURE__ */ defineNuxtPlugin({
name: "i18n:plugin:ssg-detect",
dependsOn: ["i18n:plugin", "i18n:plugin:route-locale-detect"],
@@ -6011,11 +6142,12 @@ const plugins = [
route_locale_detect__HPHJq3Jg7gwhwgKEI8tQavopSAjmrCSPXl9HgL2h9U,
preload_30FByJAs5vQa4mNNQLX15KPGCCVjIGrzdTjh6ve5W24,
i18n_EI7LsD1KYQADczz5hrChviGQCdVM8yUkvFEZLJpmnvM,
api_jy9dy79pM_nYQuRKPrcfNg56p_gKkzw9SekUTZgAenc,
ssg_detect_IpHCGcQQ_IR5Rl99qyukWoMA9fJGfuTYyoksTzy81cs
];
const layouts = {
blank: defineAsyncComponent(() => import('./blank-DWT4RB69.mjs').then((m) => m.default || m)),
default: defineAsyncComponent(() => import('./default-DOjdWE8b.mjs').then((m) => m.default || m))
default: defineAsyncComponent(() => import('./default-C9mWt9Pc.mjs').then((m) => m.default || m))
};
const routeRulesMatcher = _routeRulesMatcher;
const LayoutLoader = defineComponent({
@@ -6299,7 +6431,7 @@ const _sfc_main$1 = {
const statusText = _error.statusMessage ?? (is404 ? "Page Not Found" : "Internal Server Error");
const description = _error.message || _error.toString();
const stack = void 0;
const _Error404 = defineAsyncComponent(() => import('./error-404-Bkg5lg69.mjs'));
const _Error404 = defineAsyncComponent(() => import('./error-404-DPt4byml.mjs'));
const _Error = defineAsyncComponent(() => import('./error-500-DfEH3Z64.mjs'));
const ErrorTemplate = is404 ? _Error404 : _Error;
return (_ctx, _push, _parent, _attrs) => {
@@ -6392,5 +6524,5 @@ let entry;
}
const entry_default = ((ssrContext) => entry(ssrContext));
export { useRouter as a, useI18n as b, useCookie as c, defineNuxtRouteMiddleware as d, entry_default as default, encodeRoutePath as e, useNuxtApp as f, useRuntimeConfig as g, nuxtLinkDefaults as h, navigateTo as n, resolveRouteObject as r, useHead as u };
export { useRouter as a, useAuthStore as b, useCookie as c, useI18n as d, entry_default as default, defineNuxtRouteMiddleware as e, encodeRoutePath as f, useNuxtApp as g, useRuntimeConfig as h, nuxtLinkDefaults as i, navigateTo as n, resolveRouteObject as r, useHead as u };
//# sourceMappingURL=server.mjs.map