Files
drivetimeplaner/www/fahrschuldesk.de/dist/assets/TenantEdit-TJEJ_0TK.js
Hermes Agent 5d87e4975c Add HttpOnly cookie auth for cross-domain SPA login
Problem: Frontend JS bundle used credentials:'same-origin' which
dropped cookies on cross-domain requests. Login worked (200) but
the subsequent /auth/me check returned 401, leaving the user stuck
on the login screen.

Fix:
- AuthController now sets a dtp_jwt HttpOnly cookie on login/refresh
- Cookie uses Domain=.fahrschultermin.de (shared between frontend
  and api subdomain), Secure, SameSite=Lax, Max-Age=8h
- JwtMiddleware reads JWT from Authorization header OR cookie
- Added AuthController::me() endpoint (was missing, caused 500)
- Logout endpoint clears the cookie
- Frontend index.php patches fetch() to use credentials:'include'
  for all /api/v1/* calls
2026-06-04 20:33:31 +02:00

2 lines
3.9 KiB
JavaScript
Executable File

import{o as k,f as o,b as t,t as u,A as r,y as v,x as w,F as h,l as M,e as $,a as d,k as b,q as C,j as i,n as S}from"./index-CeMVzSB6.js";const V={class:"flex items-center gap-4 mb-6"},A={class:"text-2xl font-bold text-slate-800"},B={key:0,class:"text-center py-12 text-slate-500"},E={key:1,class:"grid gap-6"},F={class:"bg-white rounded-xl shadow-sm p-6"},T={class:"grid grid-cols-2 gap-4"},U={class:"bg-white rounded-xl shadow-sm p-6"},j={class:"space-y-2"},L={class:"font-medium"},N={class:"text-sm text-slate-500"},R=["onClick"],z={__name:"TenantEdit",setup(_){const g=C(),l=b(null),c=b([]),m=b(!0);async function x(){m.value=!0;try{const[a,e]=await Promise.all([d.get(`/admin/tenants/${g.params.id}`),d.get("/admin/platform-modules")]);l.value=a.data.data,c.value=e.data.data}catch(a){console.error(a)}finally{m.value=!1}}function p(a){var e,n;return(n=(e=l.value)==null?void 0:e.modules)==null?void 0:n.some(s=>s.id===a&&s.status==="enabled")}async function f(a){const e=p(a.id);try{e?await d.delete(`/admin/tenants/${l.value.id}/modules/${a.id}`):await d.post(`/admin/tenants/${l.value.id}/modules`,{module_id:a.id}),await x()}catch(n){console.error(n)}}async function y(){try{await d.put(`/admin/tenants/${l.value.id}`,{name:l.value.name,email:l.value.email,phone:l.value.phone,status:l.value.status}),alert("Gespeichert!")}catch(a){console.error(a),alert("Fehler beim Speichern")}}return k(x),(a,e)=>{var n;return i(),o("div",null,[t("div",V,[t("button",{onClick:e[0]||(e[0]=s=>a.$router.back()),class:"p-2 rounded-lg hover:bg-slate-100"},[...e[5]||(e[5]=[t("svg",{class:"w-5 h-5 text-slate-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1)])]),t("div",null,[t("h1",A,u(((n=l.value)==null?void 0:n.name)||"Laden..."),1),e[6]||(e[6]=t("p",{class:"text-slate-500 text-sm"},"Fahrschule bearbeiten",-1))])]),m.value?(i(),o("div",B,"Laden...")):l.value?(i(),o("div",E,[t("div",F,[e[12]||(e[12]=t("h2",{class:"text-lg font-semibold mb-4"},"Stammdaten",-1)),t("div",T,[t("div",null,[e[7]||(e[7]=t("label",{class:"block text-sm font-medium text-slate-700 mb-1"},"Name",-1)),r(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>l.value.name=s),class:"w-full px-4 py-2 rounded-lg border border-slate-300"},null,512),[[v,l.value.name]])]),t("div",null,[e[8]||(e[8]=t("label",{class:"block text-sm font-medium text-slate-700 mb-1"},"E-Mail",-1)),r(t("input",{"onUpdate:modelValue":e[2]||(e[2]=s=>l.value.email=s),class:"w-full px-4 py-2 rounded-lg border border-slate-300"},null,512),[[v,l.value.email]])]),t("div",null,[e[9]||(e[9]=t("label",{class:"block text-sm font-medium text-slate-700 mb-1"},"Telefon",-1)),r(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>l.value.phone=s),class:"w-full px-4 py-2 rounded-lg border border-slate-300"},null,512),[[v,l.value.phone]])]),t("div",null,[e[11]||(e[11]=t("label",{class:"block text-sm font-medium text-slate-700 mb-1"},"Status",-1)),r(t("select",{"onUpdate:modelValue":e[4]||(e[4]=s=>l.value.status=s),class:"w-full px-4 py-2 rounded-lg border border-slate-300"},[...e[10]||(e[10]=[t("option",{value:"pending_approval"},"Ausstehend",-1),t("option",{value:"active"},"Aktiv",-1),t("option",{value:"trial"},"Testphase",-1),t("option",{value:"suspended"},"Suspendiert",-1)])],512),[[w,l.value.status]])])]),t("button",{onClick:y,class:"mt-4 px-4 py-2 bg-primary text-white rounded-lg hover:bg-primary-600"}," Speichern ")]),t("div",U,[e[13]||(e[13]=t("h2",{class:"text-lg font-semibold mb-4"},"Module",-1)),t("div",j,[(i(!0),o(h,null,M(c.value,s=>(i(),o("div",{key:s.id,class:"flex items-center justify-between p-3 bg-slate-50 rounded-lg"},[t("div",null,[t("p",L,u(s.name),1),t("p",N,u(s.description),1)]),t("button",{onClick:D=>f(s),class:S(["px-3 py-1 rounded text-sm",p(s.id)?"bg-green-100 text-green-700":"bg-slate-200 text-slate-600"])},u(p(s.id)?"Aktiv":"Inaktiv"),11,R)]))),128))])])])):$("",!0)])}}};export{z as default};