fix(auth): secure sessions and app routing

Validate sessions against the API, honor configurable base paths, and route unknown pages to 404. Keep development ports stable so user and admin apps cannot be confused.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-09-24 20:14:11 +03:30
co-authored by Copilot
parent 83edf721ba
commit 9854842ada
45 changed files with 285 additions and 184 deletions
+3
View File
@@ -0,0 +1,3 @@
import{Ct as e,G as t,J as n,N as r,Q as i,R as a,V as o,X as s,Z as c,dt as l,et as u,gt as d,ht as f,it as p,lt as m,nt as h,rt as g,st as _,v,vt as y,yt as b,z as x}from"./index-B2VD3zy8.js";import{t as S}from"./AdminPageSkeleton-BJpm6oxf.js";import{t as C}from"./BaseEmptyState-DGu6Pfui.js";var w={class:`admin-page`},T={key:2,class:`admin-table`},E={dir:`ltr`},D=[`onClick`],O={class:`field`},k={class:`field`},A={class:`field`},j={class:`field`},M=[`disabled`],N=o(p({__name:`LevelsView`,setup(o){let p=b([]),N=b(!0),P=b(!1),F=b(null),I=x(),L=y({code:``,label:``,sortOrder:0,benefitsText:``}),R=s(()=>F.value?`ویرایش سطح`:`سطح جدید`);function z(e){return e.split(`
`).map(e=>e.trim()).filter(Boolean).map(e=>({title:e}))}async function B(){N.value=!0;try{p.value=await v.list()}catch(e){I.error(e instanceof r?e.message:`بارگذاری سطوح ناموفق بود`)}finally{N.value=!1}}function V(){F.value=null,Object.assign(L,{code:``,label:``,sortOrder:p.value.length+1,benefitsText:``}),P.value=!0}function H(e){F.value=e.id,Object.assign(L,{code:e.code,label:e.label,sortOrder:e.sortOrder,benefitsText:e.benefits.map(e=>e.title).join(`
`)}),P.value=!0}async function U(){try{let e={code:L.code.trim(),label:L.label.trim(),sortOrder:L.sortOrder,benefits:z(L.benefitsText)};F.value?await v.update(F.value,e):await v.create(e),P.value=!1,I.success(`ذخیره شد`),await B()}catch(e){I.error(e instanceof r?e.message:`ذخیره ناموفق بود`)}}return _(()=>{B()}),(r,o)=>(m(),u(`div`,w,[c(`header`,{class:`admin-page__head`},[o[5]||=c(`div`,null,[c(`h1`,null,`سطوح و مزایای مشتری`),c(`p`,null,`تعریف Level داخلی CRM و مزایای هر سطح (نمایش فقط در ادمین)`)],-1),c(`button`,{type:`button`,class:`admin-btn admin-btn--primary`,onClick:V},`سطح جدید`)]),N.value?(m(),i(S,{key:0,variant:`table`})):p.value.length?(m(),u(`table`,T,[o[6]||=c(`thead`,null,[c(`tr`,null,[c(`th`,null,`کد`),c(`th`,null,`عنوان`),c(`th`,null,`مزایا`),c(`th`,null,`مشتریان`),c(`th`)])],-1),c(`tbody`,null,[(m(!0),u(n,null,l(p.value,t=>(m(),u(`tr`,{key:t.id},[c(`td`,E,e(t.code),1),c(`td`,null,e(t.label),1),c(`td`,null,e(t.benefits.map(e=>e.title).join(`، `)||`—`),1),c(`td`,null,e(t.customersCount),1),c(`td`,null,[c(`button`,{type:`button`,class:`link`,onClick:e=>H(t)},`ویرایش`,8,D)])]))),128))])])):(m(),i(C,{key:1,title:`سطحی تعریف نشده`})),g(a,{open:P.value,title:R.value,onClose:o[4]||=e=>P.value=!1},{footer:f(()=>[c(`button`,{type:`button`,class:`admin-btn admin-btn--primary`,disabled:!L.code.trim()||!L.label.trim(),onClick:U},` ذخیره `,8,M)]),default:f(()=>[c(`label`,O,[o[7]||=h(`کد`,-1),d(c(`input`,{"onUpdate:modelValue":o[0]||=e=>L.code=e,class:`admin-input`,dir:`ltr`},null,512),[[t,L.code]])]),c(`label`,k,[o[8]||=h(`عنوان`,-1),d(c(`input`,{"onUpdate:modelValue":o[1]||=e=>L.label=e,class:`admin-input`},null,512),[[t,L.label]])]),c(`label`,A,[o[9]||=h(`ترتیب`,-1),d(c(`input`,{"onUpdate:modelValue":o[2]||=e=>L.sortOrder=e,type:`number`,class:`admin-input`},null,512),[[t,L.sortOrder,void 0,{number:!0}]])]),c(`label`,j,[o[10]||=h(` مزایا (هر خط یک مورد) `,-1),d(c(`textarea`,{"onUpdate:modelValue":o[3]||=e=>L.benefitsText=e,class:`admin-input`,rows:`4`},null,512),[[t,L.benefitsText]])])]),_:1},8,[`open`,`title`])]))}}),[[`__scopeId`,`data-v-44c7f808`]]);export{N as default};