1 line
4.6 KiB
JavaScript
1 line
4.6 KiB
JavaScript
import{A as e,Ct as t,D as n,Jt as r,O as i,_ as a,b as o,ht as s,kn as c,lt as l,nr as u,s as d,t as f,v as p,x as m,xt as h,yn as g}from"./PageHeader.js";import{W as _,h as v,n as y}from"./api.js";import{C as b,S as x,w as S,x as C}from"./index.js";var w={class:`max-w-2xl space-y-6`},T={class:`text-sm`},E={key:0,class:`rounded-lg border border-border bg-card p-4 text-sm`},D={key:1,role:`alert`,class:`text-sm text-danger`},O={class:`rounded-lg border border-border bg-card p-5`},k={class:`mt-4 divide-y divide-border`},A={class:`min-w-0 flex-1 truncate`},j={key:1,class:`mt-3 text-sm text-muted-foreground`},M={class:`rounded-lg border border-border bg-card p-5 space-y-3`},N={key:0,class:`break-all rounded border border-border p-3 font-mono text-sm`,role:`status`},P={class:`rounded-lg border border-border bg-card p-5`},F={class:`block space-y-1 text-sm`,for:`current-password`},I={class:`block space-y-1 text-sm`,for:`new-password`},L=e({__name:`AccountPage`,setup(e){let L=g(``),R=()=>J(async()=>{L.value=(await y.recoveryCode()).code}),z=x(),B=g([]),V=g(``),H=g(!1),U=g(``),W=g(``),G=g(``),K=a(()=>C(z.status?.public_url??``));async function q(){try{B.value=(await y.passkeys()).passkeys}catch(e){V.value=String(e.message||e)}}l(q);async function J(e){H.value=!0,V.value=``;try{await e()}catch(e){V.value=String(e.message||e)}finally{H.value=!1}}let Y=()=>J(async()=>{await b(!0,U.value),U.value=``,await q()}),X=e=>J(async()=>{await y.deletePasskey(e),await q()}),Z=()=>J(async()=>{await y.changePassword(W.value,G.value),W.value=G.value=``,window.location.assign(`/`)});return(e,a)=>{let l=t(`RouterLink`);return s(),m(`div`,w,[i(f,{title:`Your account`}),p(`p`,T,u(c(z).status?.user?.display_name),1),e.$route.query.welcome?(s(),m(`p`,E,[a[5]||=n(`Your organisation and admin account are ready. Add a passkey below, `,-1),i(l,{class:`underline`,to:`/access`},{default:r(()=>[...a[3]||=[n(`add accounts`,-1)]]),_:1}),a[6]||=n(`, or `,-1),i(l,{class:`underline`,to:`/access/authentication`},{default:r(()=>[...a[4]||=[n(`configure OIDC`,-1)]]),_:1}),a[7]||=n(`.`,-1)])):o(``,!0),V.value?(s(),m(`p`,D,[n(u(V.value)+` `,1),a[8]||=p(`a`,{class:`underline`,href:`/?reauth=1`},`Sign in again`,-1)])):o(``,!0),p(`section`,O,[a[14]||=p(`h2`,{class:`font-medium`},`Passkeys`,-1),a[15]||=p(`p`,{class:`mt-1 text-sm text-muted-foreground`},`Sign in with your device or security key.`,-1),p(`ul`,k,[(s(!0),m(d,null,h(B.value,e=>(s(),m(`li`,{key:e.id,class:`flex items-center gap-3 py-2 text-sm`},[p(`span`,A,u(e.name),1),i(c(v),{variant:`ghost`,size:`sm`,disabled:H.value,onClick:t=>X(e.id)},{default:r(()=>[...a[9]||=[n(`Remove`,-1)]]),_:1},8,[`disabled`,`onClick`])]))),128))]),K.value?(s(),m(`form`,{key:0,class:`mt-3 flex flex-wrap gap-2`,onSubmit:_(Y,[`prevent`])},[i(c(S),{modelValue:U.value,"onUpdate:modelValue":a[0]||=e=>U.value=e,"aria-label":`Passkey name`,placeholder:`Passkey name (optional)`,maxlength:`200`,class:`min-w-40 flex-1`},null,8,[`modelValue`]),i(c(v),{type:`submit`,disabled:H.value},{default:r(()=>[...a[10]||=[n(`Add passkey`,-1)]]),_:1},8,[`disabled`])],32)):(s(),m(`p`,j,[a[12]||=n(`Open Archie at its configured HTTPS domain, or localhost, in a browser that supports passkeys. The instance URL is managed in `,-1),i(l,{class:`underline`,to:`/access/authentication`},{default:r(()=>[...a[11]||=[n(`Authentication settings`,-1)]]),_:1}),a[13]||=n(`.`,-1)]))]),p(`section`,M,[a[17]||=p(`h2`,{class:`font-medium`},`Recovery code`,-1),a[18]||=p(`p`,{class:`text-sm text-muted-foreground`},`Save this once-only code somewhere safe. It resets your password if you lose access. Generating a new code replaces the previous one.`,-1),i(c(v),{disabled:H.value,onClick:R},{default:r(()=>[...a[16]||=[n(`Generate recovery code`,-1)]]),_:1},8,[`disabled`]),L.value?(s(),m(`p`,N,u(L.value),1)):o(``,!0)]),p(`section`,P,[a[23]||=p(`h2`,{class:`font-medium`},`Change password`,-1),p(`form`,{class:`mt-4 max-w-sm space-y-3`,onSubmit:_(Z,[`prevent`])},[p(`label`,F,[a[19]||=n(`Current password`,-1),i(c(S),{id:`current-password`,modelValue:W.value,"onUpdate:modelValue":a[1]||=e=>W.value=e,type:`password`,autocomplete:`current-password`,required:``},null,8,[`modelValue`])]),p(`label`,I,[a[20]||=n(`New password`,-1),i(c(S),{id:`new-password`,modelValue:G.value,"onUpdate:modelValue":a[2]||=e=>G.value=e,type:`password`,autocomplete:`new-password`,required:``,minlength:`15`,maxlength:`1024`},null,8,[`modelValue`])]),a[22]||=p(`p`,{class:`text-xs text-muted-foreground`},`Changing your password signs out all your sessions.`,-1),i(c(v),{type:`submit`,disabled:H.value},{default:r(()=>[...a[21]||=[n(`Change password`,-1)]]),_:1},8,[`disabled`])],32)])])}}});export{L as default}; |