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,11 +1,11 @@
import * as Vue from "vue";
import { shallowReactive, reactive, effectScope, getCurrentScope, hasInjectionContext, getCurrentInstance as getCurrentInstance$1, inject, toRef, shallowRef, isReadonly, isRef, isShallow, isReactive, toRaw, defineComponent, createElementBlock, provide, cloneVNode, h, ref, unref, onScopeDispose, computed, Fragment, createVNode, Text, defineAsyncComponent, Suspense, nextTick, mergeProps, withCtx, useSSRContext, onErrorCaptured, onServerPrefetch, resolveDynamicComponent, createApp } from "vue";
import { hasInjectionContext, getCurrentInstance as getCurrentInstance$1, shallowReactive, reactive, effectScope, getCurrentScope, inject, toRef, shallowRef, isReadonly, isRef, isShallow, isReactive, toRaw, defineComponent, createElementBlock, provide, cloneVNode, h, ref, unref, onScopeDispose, computed, Fragment, createVNode, Text, defineAsyncComponent, Suspense, nextTick, mergeProps, withCtx, useSSRContext, onErrorCaptured, onServerPrefetch, resolveDynamicComponent, createApp } from "vue";
import { $fetch as $fetch$1 } from "/app/node_modules/ofetch/dist/node.mjs";
import { baseURL } from "#internal/nuxt/paths";
import { createHooks } from "/app/node_modules/hookable/dist/index.mjs";
import { getContext, executeAsync } from "/app/node_modules/unctx/dist/index.mjs";
import { sanitizeStatusCode, createError as createError$1, appendHeader, getRequestHeader, setCookie, getCookie, deleteCookie, getRequestURL } from "/app/node_modules/h3/dist/index.mjs";
import { shouldHydrate, setActivePinia, createPinia } from "pinia";
import { shouldHydrate, setActivePinia, createPinia, defineStore } from "pinia";
import { defu, createDefu } from "/app/node_modules/defu/dist/defu.mjs";
import { START_LOCATION, createMemoryHistory, createRouter, useRoute as useRoute$1, RouterView } from "vue-router";
import { hasProtocol, joinURL, parseURL, encodePath, decodePath, withQuery, isScriptProtocol, parsePath, parseQuery, withoutTrailingSlash } from "/app/node_modules/ufo/dist/index.mjs";
@@ -473,13 +473,13 @@ const _routes = [
name: "login",
path: "/login",
meta: __nuxt_page_meta || {},
component: () => import("./_nuxt/login-Dx4mHuUH.js")
component: () => import("./_nuxt/login-DOiXgKDi.js")
},
{
name: "garages",
path: "/garages",
meta: { "middleware": "auth" },
component: () => import("./_nuxt/index-o-V5Lz0_.js")
component: () => import("./_nuxt/index-CzKBE-M2.js")
},
{
name: "packages",
@@ -491,13 +491,12 @@ const _routes = [
name: "permissions",
path: "/permissions",
meta: { "middleware": "auth" },
component: () => import("./_nuxt/index-D2n0yf-2.js")
component: () => import("./_nuxt/index-DgwDY6Ie.js")
},
{
name: "garages-id",
path: "/garages/:id()",
meta: { "middleware": "auth" },
component: () => import("./_nuxt/index-JpXwtL-Z.js")
component: () => import("./_nuxt/index-1I7UC9HP.js")
}
];
const _wrapInTransition = (props, children) => {
@@ -642,7 +641,7 @@ const globalMiddleware = [
manifest_45route_45rule
];
const namedMiddleware = {
auth: () => import("./_nuxt/auth-9ekP0oPk.js")
auth: () => import("./_nuxt/auth-B3jrOAhu.js")
};
Object.assign(/* @__PURE__ */ Object.create(null), {});
const pageIslandRoutes = Object.assign(/* @__PURE__ */ Object.create(null), {});
@@ -1512,7 +1511,7 @@ const localeLoaders = {
{
key: "locale_hu_46json_ee06c965",
load: () => import(
"./_nuxt/hu-B3JxlqZo.js"
"./_nuxt/hu-Ck1VzT5S.js"
/* webpackChunkName: "locale_hu_46json_ee06c965" */
),
cache: true
@@ -1522,7 +1521,7 @@ const localeLoaders = {
{
key: "locale_en_46json_0b63539c",
load: () => import(
"./_nuxt/en-WIj2pBfh.js"
"./_nuxt/en-BI6r-iRW.js"
/* webpackChunkName: "locale_en_46json_0b63539c" */
),
cache: true
@@ -1662,7 +1661,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
@@ -6736,7 +6735,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,
@@ -6819,6 +6818,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"],
@@ -6840,11 +6971,12 @@ const plugins = [
route_locale_detect__HPHJq3Jg7gwhwgKEI8tQavopSAjmrCSPXl9HgL2h9U,
preload_30FByJAs5vQa4mNNQLX15KPGCCVjIGrzdTjh6ve5W24,
i18n_EI7LsD1KYQADczz5hrChviGQCdVM8yUkvFEZLJpmnvM,
api_jy9dy79pM_nYQuRKPrcfNg56p_gKkzw9SekUTZgAenc,
ssg_detect_IpHCGcQQ_IR5Rl99qyukWoMA9fJGfuTYyoksTzy81cs
];
const layouts = {
blank: defineAsyncComponent(() => import("./_nuxt/blank-DWT4RB69.js").then((m) => m.default || m)),
default: defineAsyncComponent(() => import("./_nuxt/default-DOjdWE8b.js").then((m) => m.default || m))
default: defineAsyncComponent(() => import("./_nuxt/default-C9mWt9Pc.js").then((m) => m.default || m))
};
const routeRulesMatcher = _routeRulesMatcher;
const LayoutLoader = defineComponent({
@@ -7128,7 +7260,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("./_nuxt/error-404-Bkg5lg69.js"));
const _Error404 = defineAsyncComponent(() => import("./_nuxt/error-404-DPt4byml.js"));
const _Error = defineAsyncComponent(() => import("./_nuxt/error-500-DfEH3Z64.js"));
const ErrorTemplate = is404 ? _Error404 : _Error;
return (_ctx, _push, _parent, _attrs) => {
@@ -7222,14 +7354,15 @@ let entry;
const entry_default = ((ssrContext) => entry(ssrContext));
export {
useRouter as a,
useI18n as b,
useAuthStore as b,
useCookie as c,
defineNuxtRouteMiddleware as d,
useI18n as d,
entry_default as default,
encodeRoutePath as e,
useNuxtApp as f,
useRuntimeConfig as g,
nuxtLinkDefaults as h,
defineNuxtRouteMiddleware as e,
encodeRoutePath as f,
useNuxtApp as g,
useRuntimeConfig as h,
nuxtLinkDefaults as i,
navigateTo as n,
resolveRouteObject as r,
useHead as u