PageSourceSearch

https://arbizal.com/assets/AccountPage-BkAm1115.js

js arbizal.com collected 2026-10-05 22:44:57 UTC 17,747 bytes, 4 lines download raw bytes

1import{f as le,cq as Ae,_ as b,cr as Pe,r as n,j as e,aw as l,X as Fe,V as t,cs as H,T as ve,ct as Q,ar as U,as as q,at as z,au as B,av as I,cu as ne,cv as ye,aD as O,a9 as L,cw as Re,cx as Me,cy as Te,cz as Le,cA as Ue,bM as qe,a2 as ze,c as Be,d as Ie,ae as Oe,cB as Ve,cC as Ke,bm as Ye,ad as _e,K as Ge,b1 as He,cD as Qe}from"./200-BdW3ad50.js";import{C as be}from"./checkbox-Ir06txGX.js";import{I as j}from"./input-BgUnqCyB.js";import{C as V,a as K,b as Y,d as _,c as G}from"./card-DZwQZ4QR.js";import{B as re}from"./badge-CGVeRweQ.js";import{S as ce}from"./separator-BrGfyMCI.js";function We(){const{data:a,refetch:u}=le(Ae),h=b(Re),N=b(Me),A=b(Te),g=b(Le),P=b(Ue),w=Pe(),x=n.useRef(null);n.useEffect(()=>{x.current===null&&a&&(x.current=!a.mfaEnabled)},[a]);const[c,o]=n.useState("idle"),[d,f]=n.useState(""),[v,C]=n.useState(null),[p,k]=n.useState(""),[S,F]=n.useState([]),[R,M]=n.useState(!1),[r,D]=n.useState(""),[i,m]=n.useState(!1),[Ne,ie]=n.useState(!1),[W,oe]=n.useState(""),[de,X]=n.useState(""),[Ce,me]=n.useState(!1),[$,J]=n.useState(""),[y,ue]=n.useState([]),[he,xe]=n.useState(!1),[pe,Z]=n.useState(""),T=()=>{o("idle"),f(""),C(null),k(""),F([]),M(!1),D("")},ke=()=>{if(x.current===!0){window.location.href="/";return}T()},ee=()=>{ie(!1),oe(""),X("")},se=()=>{me(!1),J(""),ue([]),xe(!1),Z("")},je=async()=>{m(!0),D("");try{const s=await h({currentPassword:d});C({secret:s.secret,qrCodeDataUrl:s.qrCodeDataUrl}),o("qr"),w()}catch(s){D(s instanceof Error?s.message:"Failed to start enrollment")}finally{m(!1)}},ge=async()=>{m(!0),D("");try{const s=await N({code:p});F(s.backupCodes),o("backup-codes"),u(),w()}catch(s){D(s instanceof Error?s.message:"Invalid code")}finally{m(!1)}},Se=async()=>{m(!0),X("");try{await A({currentPassword:W}),ee(),u(),w()}catch(s){X(s instanceof Error?s.message:"Failed to disable MFA")}finally{m(!1)}},De=async()=>{m(!0),Z("");try{const s=await g({currentPassword:$});ue(s.backupCodes),J(""),u()}catch(s){Z(s instanceof Error?s.message:"Failed to regenerate codes")}finally{m(!1)}},Ee=async s=>{try{await P({deviceId:s}),u()}catch{}},ae=s=>{navigator.clipboard.writeText(s).catch(()=>{})},we=s=>{const E=new Blob([new Uint8Array(new TextEncoder().encode(s.join(`
2`)))],{type:"text/plain"}),fe=URL.createObjectURL(E),te=document.createElement("a");te.href=fe,te.download="arbizal-backup-codes.txt",te.click(),URL.revokeObjectURL(fe)};return a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(l,{className:"text-muted-foreground",children:"Two-Factor Authentication"}),a.mfaEnabled?e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-sm",children:[e.jsx(Fe,{className:"h-4 w-4 text-green-600"}),e.jsxs("span",{className:"font-medium",children:["Enabled",a.enrolledAt&&` since ${new Date(a.enrolledAt).toLocaleDateString()}`]})]}):e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add an extra layer of security with an authenticator app."})]}),a.mfaEnabled?e.jsx(t,{variant:"outline",size:"sm",onClick:()=>ie(!0),className:"border-destructive/40 text-destructive hover:bg-destructive/10 hover:text-destructive",children:"Disable MFA"}):e.jsx(t,{onClick:()=>o("password"),children:"Enable MFA"})]}),a.mfaEnabled&&e.jsxs("div",{className:"space-y-3 pt-2",children:[a.backupCodesRemaining<=2&&e.jsxs(H,{
2className:"border-amber-400 bg-amber-50 text-amber-900 [&>svg]:text-amber-600",children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsxs(Q,{children:["You're low on backup codes (",a.backupCodesRemaining," ","remaining). Regenerate them to keep account recovery available."]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Backup codes: ",a.backupCodesRemaining," of 10 remaining"]}),e.jsx(t,{variant:"ghost",size:"sm",onClick:()=>me(!0),children:"Regenerate codes"})]}),a.trustedDevices.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{className:"text-muted-foreground",children:"Trusted devices"}),e.jsx("div",{className:"space-y-1.5",children:a.trustedDevices.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[e.jsxs("span",{className:"truncate",children:[s.label||"Unknown device"," —"," ",e.jsxs("span",{className:"text-muted-foreground",children:["last used"," ",new Date(s.lastUsedAt).toLocaleDateString()]})]}),e.jsx(t,{variant:"ghost",size:"sm",onClick:()=>Ee(s.id),className:"text-destructive hover:text-destructive",children:"Revoke"})]},s.id))})]})]}),e.jsx(U,{open:c!=="idle",onOpenChange:s=>{if(!s&&!i){if(c==="backup-codes"&&x.current===!0){window.location.href="/";return}T()}},children:e.jsxs(q,{className:"sm:max-w-md",children:[e.jsxs(z,{children:[e.jsxs(B,{children:[c==="password"&&"Confirm your password",c==="qr"&&"Scan with your authenticator",c==="verify"&&"Enter the 6-digit code",c==="backup-codes"&&"Save your backup codes"]}),e.jsxs(I,{children:[c==="password"&&"We'll verify your current password before generating an MFA secret.",c==="qr"&&"Use Google Authenticator, 1Password, Authy, or any TOTP app.",c==="verify"&&"Open your authenticator app and enter the current code.",c==="backup-codes"&&"Use these one-time codes if you lose access to your authenticator. They won't be shown again."]})]}),c==="password"&&e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(l,{htmlFor:"enroll-password",children:"Current password"}),e.jsx(j,{id:"enroll-password",type:"password",value:d,onChange:s=>f(s.target.value),onKeyDown:s=>s.key==="Enter"&&d&&je(),autoFocus:!0}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]}),c==="qr"&&v&&e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsx("div",{className:"flex justify-center rounded-md border bg-white p-4",children:e.jsx("img",{src:v.qrCodeDataUrl,alt:"MFA QR code",width:200,height:200})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{className:"text-muted-foreground",children:"Can't scan? Enter this code manually:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 rounded-md border bg-muted px-3 py-2 font-mono text-sm break-all",children:v.secret}),e.jsx(t,{variant:"outline",size:"sm",onClick:()=>ae(v.secret),children:e.jsx(ne,{className:"h-4 w-4"})})]})]})]}),c==="verify"&&e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(j,{type:"text",inputMode:"numeric",value:p,onChange:s=>k(s.target.value.replace(/\D/g,"").slice(0,6)),onKeyDown:s=>s.key==="Enter"&&p.length===6&&ge(),placeholder:"000000",maxLength:6,className:"text-center font-mono text-xl tracking-widest",autoFocus:!0}),r&&e.jsx("p",{className:"text-sm text-destructive",children:r})]}),c==="backup-codes"&&e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs(H,{
2className:"border-amber-400 bg-amber-50 text-amber-900 [&>svg]:text-amber-600",children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsx(Q,{children:"Save these codes somewhere safe. They won't be shown again."})]}),e.jsx("div",{className:"rounded-md border bg-muted p-3 font-mono text-sm",children:S.map((s,E)=>e.jsxs("div",{className:"py-0.5",children:[s.slice(0,4),"-",s.slice(4)]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>ae(S.join(`
3`)),children:[e.jsx(ne,{className:"mr-2 h-3.5 w-3.5"}),"Copy all"]}),e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>we(S),children:[e.jsx(ye,{className:"mr-2 h-3.5 w-3.5"}),"Download .txt"]})]}),e.jsxs("label",{className:"flex items-center gap-2 pt-2 text-sm",children:[e.jsx(be,{checked:R,onCheckedChange:s=>M(s===!0)}),e.jsx("span",{children:"I've saved these codes"})]})]}),e.jsxs(O,{children:[c==="password"&&e.jsxs(e.Fragment,{children:[e.jsx(t,{variant:"outline",onClick:T,disabled:i,children:"Cancel"}),e.jsx(t,{onClick:je,disabled:i||!d,children:i?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying…"]}):"Continue"})]}),c==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx(t,{variant:"outline",onClick:T,children:"Cancel"}),e.jsx(t,{onClick:()=>o("verify"),children:"Next"})]}),c==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx(t,{variant:"outline",onClick:()=>o("qr"),disabled:i,children:"Back"}),e.jsx(t,{onClick:ge,disabled:i||p.length!==6,children:i?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying…"]}):"Verify & enable"})]}),c==="backup-codes"&&e.jsx(t,{onClick:ke,disabled:!R,children:"Done"})]})]})}),e.jsx(U,{open:Ne,onOpenChange:s=>{!s&&!i&&ee()},children:e.jsxs(q,{className:"sm:max-w-md",children:[e.jsxs(z,{children:[e.jsx(B,{children:"Disable multi-factor authentication?"}),e.jsx(I,{children:"Confirm your password to turn off MFA on this account. This weakens your account's security and may be blocked by your organization's compliance settings."})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(l,{htmlFor:"disable-password",children:"Current password"}),e.jsx(j,{id:"disable-password",type:"password",value:W,onChange:s=>oe(s.target.value),autoFocus:!0}),de&&e.jsx("p",{className:"text-sm text-destructive",children:de})]}),e.jsxs(O,{children:[e.jsx(t,{variant:"outline",onClick:ee,disabled:i,children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:Se,disabled:i||!W,children:i?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"mr-2 h-4 w-4 animate-spin"}),"Disabling…"]}):"Disable MFA"})]})]})}),e.jsx(U,{open:Ce,onOpenChange:s=>{!s&&!i&&se()},children:e.jsxs(q,{className:"sm:max-w-md",children:[e.jsxs(z,{children:[e.jsx(B,{children:"Regenerate backup codes"}),e.jsx(I,{children:y.length===0?"Confirm your password. Your previous codes will stop working immediately.":"Save these new codes — your old codes are now invalid."})]}),y.length===0?e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(l,{htmlFor:"regen-password",children:"Current password"}),e.jsx(j,{id:"regen-password",type:"password",value:$,onChange:s=>J(s.target.value),autoFocus:!0}),pe&&e.jsx("p",{className:"text-sm text-destructive",children:pe})]}):e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx("div",{className:"rounded-md border bg-muted p-3 font-mono text-sm",children:y.map((s,E)=>e.jsxs("div",{className:"py-0.5",children:[s.slice(0,4),"-",s.slice(4)]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>ae(y.join(`
4`)),children:[e.jsx(ne,{className:"mr-2 h-3.5 w-3.5"}),"Copy all"]}),e.jsxs(t,{variant:"outline",size:"sm",onClick:()=>we(y),children:[e.jsx(ye,{className:"mr-2 h-3.5 w-3.5"}),"Download .txt"]})]}),e.jsxs("label",{className:"flex items-center gap-2 pt-2 text-sm",children:[e.jsx(be,{checked:he,onCheckedChange:s=>xe(s===!0)}),e.jsx("span",{children:"I've saved these codes"})]})]}),e.jsx(O,{children:y.length===0?e.jsxs(e.Fragment,{children:[e.jsx(t,{variant:"outline",onClick:se,disabled:i,children:"Cancel"}),e.jsx(t,{onClick:De,disabled:i||!$,children:i?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"mr-2 h-4 w-4 animate-spin"}),"Regenerating…"]}):"Regenerate"})]}):e.jsx(t,{onClick:se,disabled:!he,children:"Done"})})]})})]}):null}function Xe(){const{data:a}=le(qe);return(a??[]).filter(h=>h.enabled).length===0?null:e.jsxs(V,{children:[e.jsxs(K,{children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(ze,{className:"h-5 w-5"}),"Connect an assistant"]}),e.jsx(_,{children:"Let Claude or ChatGPT answer questions using your organization's documents, using your normal Arbizal sign-in."})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Step-by-step instructions for each assistant, and the list of assistants you have already connected — which you can disconnect at any time."}),e.jsx(t,{asChild:!0,variant:"outline",children:e.jsx(Be,{to:Ie.ConnectedAppsRoute.to,children:"Set up or manage connections"})})]})]})}function ts({user:a}){const[u,h]=n.useState(!1),[N,A]=n.useState(""),[g,P]=n.useState(""),[w,x]=n.useState(""),[c,o]=n.useState(null),[d,f]=n.useState(!1),v=b(Qe);function C(){A(""),P(""),x(""),o(null),f(!1)}function p(r){h(r),r||C()}async function k(){if(o(null),!N||!g){o("Enter your current password and a new password.");return}
4if(g!==w){o("New password and confirmation do not match.");return}f(!0);try{await v({currentPassword:N,newPassword:g}),C(),h(!1)}catch(r){o(r?.message??"Could not change password."),f(!1)}}const{data:S}=le(He),F=S?.requireEnrollment===!0,R=r=>{switch(r){case"ADMIN":return"bg-purple-100 text-purple-700";case"TEAM_LEADER":return"bg-blue-100 text-blue-700";default:return"bg-gray-100 text-gray-700"}},M=r=>{switch(r){case"ADMIN":return"Administrator";case"TEAM_LEADER":return"Team Leader";case"MEMBER":return"Member";default:return r}};return e.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-10",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[e.jsx(Oe,{className:"h-6 w-6"}),"Account Settings"]}),e.jsx("p",{className:"text-muted-foreground",children:"Manage your account information and preferences"})]}),e.jsxs("div",{className:"space-y-6",children:[F&&e.jsxs(H,{className:"border-amber-400 bg-amber-50 text-amber-900 [&>svg]:text-amber-600",children:[e.jsx(Ve,{className:"h-4 w-4"}),e.jsx(Ke,{children:"Multi-factor authentication required"}),e.jsxs(Q,{children:["Your organization requires MFA. Enroll under"," ",e.jsx("strong",{children:"Two-Factor Authentication"})," below to continue — you'll be brought back here on every page until enrollment is complete."]})]}),e.jsxs(V,{children:[e.jsxs(K,{children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ye,{className:"h-5 w-5"}),"Profile Information"]}),e.jsx(_,{children:"Your account details and contact information"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Email Address"}),e.jsx("p",{className:"mt-1 font-medium",children:a.email||"Not set"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Username"}),e.jsx("p",{className:"mt-1 font-medium",children:a.username||"Not set"})]})]}),e.jsx(ce,{}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Account Created"}),e.jsx("p",{className:"mt-1 font-medium",children:a.createdAt?new Date(a.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"Unknown"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Last Login"}),e.jsx("p",{className:"mt-1 font-medium",children:a.lastLoginAt?new Date(a.lastLoginAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Unknown"})]})]})]})]}),e.jsxs(V,{children:[e.jsxs(K,{children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(_e,{className:"h-5 w-5"}),"Role & Permissions"]}),e.jsx(_,{children:"Your access level and permissions within the platform"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Role"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(re,{className:R(a.role),children:M(a.role)}),a.isAdmin&&e.jsx(re,{className:"bg-purple-100 text-purple-700",children:"Platform Admin"})]})]})}),e.jsx(ce,{}),e.jsxs("div",{children:[e.jsx(l,{className:"text-muted-foreground",children:"Account Status"}),e.jsx("div",{className:"mt-1",children:e.jsx(re,{className:"bg-green-100 text-green-700",children:"Active"})})]})]})]}),e.jsxs(V,{children:[e.jsxs(K,{children:[e.jsxs(Y,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ge,{className:"h-5 w-5"}),"Security"]}),e.jsx(_,{children:"Manage your password and security settings"})]}),e.jsxs(G,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx(l,{className:"text-muted-foreground",children:"Password"})}),e.jsx(t,{variant:"outline",onClick:()=>h(!0),children:"Change Password"})]}),e.jsx(ce,{}),e.jsx(We,{})]})]}),e.jsx(Xe,{})]}),e.jsx(U,{open:u,onOpenChange:p,children:e.jsxs(q,{children:[e.jsxs(z,{children:[e.jsx(B,{children:"Change Password"}),e.jsx(I,{children:"Enter your current password and choose a new one."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"current-password",children:"Current Password"}),e.jsx(j,{id:"current-password",type:"password",placeholder:"Enter current password",autoComplete:"current-password",value:N,onChange:r=>A(r.target.value),disabled:d})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"new-password",children:"New Password"}),e.jsx(j,{id:"new-password",type:"password",placeholder:"Enter new password",autoComplete:"new-password",value:g,onChange:r=>P(r.target.value),disabled:d})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"confirm-password",children:"Confirm New Password"}),e.jsx(j,{id:"confirm-password",type:"password",placeholder:"Confirm new password",autoComplete:"new-password",value:w,onChange:r=>x(r.target.value),disabled:d,onKeyDown:r=>{r.key==="Enter"&&!d&&k()}})]}),c&&e.jsx(H,{variant:"destructive",children:e.jsx(Q,{children:c})})]}),e.jsxs(O,{children:[e.jsx(t,{variant:"outline",onClick:()=>p(!1),disabled:d,children:"Cancel"}),e.jsx(t,{onClick:k,disabled:d,children:d?"Updating…":"Update Password"})]})]})})]})}export{ts as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.