PageSourceSearch

https://enterprise-kc.com/static/js/5534.1d6e8ac8.chunk.js

js enterprise-kc.com collected 2026-10-07 09:55:02 UTC 15,294 bytes, 3 lines download raw bytes

1"use strict";(self.webpackChunkwebsite_react=self.webpackChunkwebsite_react||[]).push([[5534],{65534:(ne,U,h)=>{h.r(U),h.d(U,{default:()=>X});var e=h(70579),_=h(79438),R=h(63957),l=h(65043),S=h(35475),Y=h(61201),y=h(58359),$=Object.defineProperty,V=Object.defineProperties,z=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,O=(r,n,m)=>n in r?$(r,n,{enumerable:!0,configurable:!0,writable:!0,value:m}):r[n]=m,u=(r,n)=>{for(var m in n||(n={}))G.call(n,m)&&O(r,m,n[m]);if(E)for(var m of E(n))Q.call(n,m)&&O(r,m,n[m]);return r},x=(r,n)=>V(r,z(n));const f={superadmin:"Superadmin",admin:"Admin",copy_editor:"Copy Editor",viewer:"Viewer"},N={currentPassword:"",newPassword:"",confirmPassword:"",reason:"",requireChange:!0},b=(r,n)=>typeof r=="string"?r:r&&typeof r=="object"&&"message"in r?String(r.message||n):n,X=()=>{const{user:r}=(0,l.useContext)(Y.A),n=(r==null?void 0:r.role)==="superadmin",[m,w]=(0,l.useState)([]),[H,F]=(0,l.useState)(!0),[D,d]=(0,l.useState)(null),[i,j]=(0,l.useState)({username:"",password:"",role:"viewer",requireChange:!0}),[C,M]=(0,l.useState)(!1),[T,L]=(0,l.useState)(!1),[A,q]=(0,l.useState)(!1),[J,I]=(0,l.useState)([]),[p,k]=(0,l.useState)(null),[c,g]=(0,l.useState)(N),[P,B]=(0,l.useState)(!1),[W,v]=(0,l.useState)(null);(0,l.useEffect)(()=>{if(!n){F(!1);return}async function s(){try{const[t,a]=await Promise.all([(0,y.lo)(),(0,y.Qh)()]);w(t.data||[]),M(Boolean(a==null?void 0:a.locked))}catch(t){d(b(t,"Failed to load users or registration settings."))}finally{F(!1)}}s()},[n]);const Z=async(s,t)=>{d(null);try{await(0,y.v_)(s,t),w(a=>a.map(o=>o.id===s?x(u({},o),{role:t}):o)),d("Role updated.")}catch(a){d(b(a,"Failed to update role."))}},ee=async s=>{if(s.preventDefault(),d(null),!i.username.trim()||!i.password){d("Username and temporary password are required.");return}L(!0);try{const t=await(0,y.kg)(i.username.trim(),i.password,i.role,i.requireChange);w(a=>[{id:t.id,username:t.username,role:t.role,created_at:t.created_at,mustChangePassword:t.mustChangePassword},...a]),j({username:"",password:"",role:"viewer",requireChange:!0}),d("User created. Share the temporary password privately.")}catch(t){d(b(t,"Failed to create user."))}finally{L(!1)}},se=async s=>{if(d(null),!!window.confirm("Remove this user account? This cannot be undone.")){I(a=>[...a,s]);try{await(0,y.hG)(s),w(a=>a.filter(o=>o.id!==s)),d("User removed.")}catch(a){d(b(a,"Failed to remove user."))}finally{I(a=>a.filter(o=>o!==s))}}},te=async()=>{d(null),q(!0);try{const s=!C;await(0,y.lR)(s),M(s),d(s?"Registration locked.":"Registration unlocked.")}catch(s){d(b(s,"Failed to update registration lock."))}finally{q(!1)}},re=s=>{k(s),g(N),v(null)},K=()=>{P||(k(null),g(N),v(null))},ae=async s=>{if(s.preventDefault(),!!p){if(v(null),c.newPassword!==c.confirmPassword){v("The temporary passwords do not match.");return}B(!0);try{const t=await(0,y.cw)(p.id,c);w(a=>a.map(o=>o.id===p.id?x(u({},o),{mustChangePassword:t.mustChangePassword}):o)),d(c.requireChange?`Password reset for ${p.username}. They must choose a new password at next sign-in.`:`Password updated for ${p.username}. Their existing sign-ins have ended.`),k(null),g(N)}catch(t){v(b(t,"We could not reset this password."))}finally{B(!1)}}};return n?(0,e.jsxs)("main",{className:"ml-64 min-h-screen bg-gray-50 px-6 py-8",children:[(0,e.jsxs)("div",{className:"max-w-6xl",children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-ekc-blue",children:"CMS access"}),(0,e.jsx)("h1",{className:"mt-1 text-3xl font-semibold tracking-tight text-gray-950",children:"User Management"}),(0,e.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-gray-600",children:"Create accounts, choose what each person can access, and safely reset a forgotten password. Passwords are never shown after they are saved."}),D&&(0,e.jsx)("div",{role:"status",className:"mt-5 rounded-md border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-950",children:D}),H?(0,e.jsx)("div",{className:"mt-8 text-gray-600",children:"Loading users\u2026"}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{"aria-labelledby":"account-settings-heading",className:"mt-8 grid gap-6 border-y border-gray-200 py-6 lg:grid-cols-2",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{id:"account-settings-heading",className:"text-lg font-semibold text-gray-950",children:"Registration"}),(0,e.jsx)("p",{className:"mt-1 text-sm leading-6 text-gray-600",children:C?"New self-registration is locked. Superadmins can still create accounts here.":"Registration is open to people who have the separate registration key."}),(0,e.jsx)("button",{type:"button",className:`mt-4 rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm ${C?"bg-red-600 hover:bg-red-700":"bg-emerald-700 hover:bg-emerald-800"} disabled:cursor-not-allowed disabled:opacity-60`,onClick:te,disabled:A,children:A?"Saving\u2026":C?"Unlock registration":"Lock registration"})]}),(0,e.jsxs)("div",{className:"lg:border-l lg:border-gray-200 lg:pl-6",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-gray-950",children:"Add a user"}),(0,e.jsx)("p",{className:"mt-1 text-sm leading-6 text-gray-600",children:"Create a temporary password and share it privately."}),(0,e.jsxs)("form",{className:"mt-4 grid gap-4 sm:grid-cols-2",onSubmit:ee,children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-sm font-medium text-gray-700",htmlFor:"newUsername",children:"Username"}),(0,e.jsx)("input",{id:"newUsername",type:"text",autoComplete:"off",className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2",value:i.username,onChange:s=>j(x(u({},i),{username:s.target.value})),required:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-sm font-medium text-gray-700",htmlFor:"newPassword",children:"Temporary password"}),(0,e.jsx)("input",{id:"newPassword",type:"password",autoComplete:"new-password",minLength:12,className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2",value:i.password,onChange:s=>j(x(u({},i),{password:s.target.value})),required:!0}),(0,e.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"At least 12 characters; do not include the username."})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"text-sm font-medium text-gray-700",htmlFor:"newRole",children:"Role"}),(0,e.jsx)("select",{id:"newRole",className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2",value:i.role,onChange:s=>j(x(u({},i),{role:s.target.value})),children:Object.keys(f).map(s=>(0,e.jsx)("option",{value:s,children:f[s]},s))})]}),(0,e.jsxs)("label",{className:"flex items-start gap-2 text-sm text-gray-700 sm:pt-7",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5 rounded border-gray-300 text-ekc-blue focus:ring-ekc-blue",checked:i.requireChange,onChange:s=>j(x(u({},i),{requireChange:s.target.checked}))}),"Require a private password at first sign-in"]}),(0,e.jsx)("button",{type:"submit",className:"justify-center rounded-md bg-ekc-blue px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-opacity-85 disabled:cursor-not-allowed disabled:opacity-60 sm:col-span-2",disabled:T,children:T?"Creating\u2026":"Create user"})]})]})]}),(0,e.jsxs)("section",{"aria-labelledby":"user-accounts-heading",className:"mt-8",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h2",{id:"user-accounts-heading",className:"text-xl font-semibold text-gray-950",children:"User accounts"}),(0,e.jsx)("p",{className:"mt-1 text-sm text-gray-600",children:"A password reset ends that person\u2019s existing CMS sign-ins."})]}),(0,e.jsx)(S.N_,{to:"/dashboard/account",className:"text-sm font-semibold text-ekc-blue underline decoration-blue-300 underline-offset-4 hover:
1decoration-ekc-blue",children:"Change your password"})]}),(0,e.jsx)("div",{className:"mt-4 overflow-x-auto border-y border-gray-200 bg-white",children:(0,e.jsxs)("table",{className:"min-w-full text-left",children:[(0,e.jsx)("thead",{className:"border-b border-gray-200 bg-gray-50",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"px-4 py-3 text-sm font-semibold text-gray-700",children:"Username"}),(0,e.jsx)("th",{className:"px-4 py-3 text-sm font-semibold text-gray-700",children:"Role"}),(0,e.jsx)("th",{className:"px-4 py-3 text-sm font-semibold text-gray-700",children:"Password status"}),(0,e.jsx)("th",{className:"px-4 py-3 text-sm font-semibold text-gray-700",children:"Created"}),(0,e.jsx)("th",{className:"px-4 py-3 text-sm font-semibold text-gray-700",children:"Actions"})]})}),(0,e.jsx)("tbody",{children:m.map(s=>{const t=s.id===(r==null?void 0:r.id),a=J.includes(s.id);return(0,e.jsxs)("tr",{className:"border-b border-gray-100 last:border-none",children:[(0,e.jsxs)("td",{className:"px-4 py-3 font-medium text-gray-950",children:[s.username,t&&(0,e.jsx)("span",{className:"ml-2 text-xs font-normal text-gray-500",children:"You"})]}),(0,e.jsx)("td",{className:"px-4 py-3",children:t?(0,e.jsx)("span",{className:"text-sm text-gray-700",children:f[s.role]}):(0,e.jsx)("select",{className:"rounded-md border border-gray-300 px-2 py-1 text-sm",value:s.role,onChange:o=>Z(s.id,o.target.value),children:Object.keys(f).map(o=>(0,e.jsx)("option",{value:o,children:f[o]},o))})}),(0,e.jsx)("td",{className:"px-4 py-3",children:s.mustChangePassword?(0,e.jsx)("span",{className:"inline-flex rounded-full bg-amber-100 px-2.5 py-1 text-xs font-semibold text-amber-900",children:"Change required"}):(0,e.jsx)("span",{className:"inline-flex rounded-full bg-emerald-50 px-2.5 py-1 text-xs font-semibold text-emerald-800",children:"Ready"})}),(0,e.jsx)("td",{className:"px-4 py-3 text-sm text-gray-500",children:s.created_at?new Date(s.created_at).toLocaleString():"\u2014"}),(0,e.jsx)("td",{className:"px-4 py-3",children:t?(0,e.jsx)(S.N_,{to:"/dashboard/account",className:"text-sm font-semibold text-ekc-blue hover:underline",children:"Update mine"}):(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,e.jsx)("button",{type:"button",className:"text-sm font-semibold text-ekc-blue hover:underline",onClick:()=>re(s),children:"Reset password"}),(0,e.jsx)("button",{type:"button",className:"text-sm font-semibold text-red-600 hover:underline disabled:opacity-60",onClick:()=>se(s.id),disabled:a,children:a?"Removing\u2026":"Remove"})]})})]},s.id)})})]})})]})]})]}),(0,e.jsx)(_.e.Root,{show:Boolean(p),as:l.Fragment,children:(0,e.jsxs)(R.l,{as:"div",className:"relative z-50",onClose:K,children:[(0,e.jsx)(_.e.Child,{as:l.Fragment,enter:"ease-out duration-150",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,e.jsx)("div",{className:"fixed inset-0 bg-gray-950/35"})}),(0,e.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,e.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,e.jsx)(_.e.Child,{as:l.Fragment,enter:"ease-out duration-150",enterFrom:"opacity-0 translate-y-2",enterTo:"opacity-100 translate-y-0",leave:"ease-in duration-100",leaveFrom:"opacity-100 translate-y-0",leaveTo:"opacity-0 translate-y-2",children:(0,e.jsxs)(R.l.Panel,{className:"w-full max-w-lg rounded-lg bg-white p-6 shadow-xl",children:[(0,e.jsxs)(R.l.Title,{className:"text-xl font-semibold text-gray-950",children:["Reset password for ",p==null?void 0:p.username]}),(0,e.jsx)("p",{className:"mt-2 text-sm leading-6 text-gray-600",children:"This ends the person\u2019s existing CMS sign-ins. Share the temporary password through a private channel."}),W&&(0,e.jsx)("div",{role:"alert",className:"mt-4 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:W}),(0,e.jsxs)("form",{onSubmit:ae,className:"mt-5 space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"resetNewPassword",className:"block text-sm font-semibold text-gray-900",children:"Temporary password"}),(0,e.jsx)("input",{id:"resetNewPassword",type:"password",autoComplete:"new-password",minLength:12,value:c.newPassword,onChange:s=>g(x(u({},c),{newPassword:s.target.value})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2.5",required:!0}),(0,e.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"At least 12 characters; do not include the username."})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"resetConfirmPassword",className:"block text-sm font-semibold text-gray-900",children:"Confirm temporary password"}),(0,e.jsx)("input",{id:"resetConfirmPassword",type:"password",autoComplete:"new-password",minLength:12,value:c.confirmPassword,onChange:s=>g(x(u({},c),{confirmPassword:s.target.value})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2.5",required:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"resetReason",className:"block text-sm font-semibold text-gray-900",children:"Reason"}),(0,e.jsx)("input",{id:"resetReason",type:"text",maxLength:250,value:c.reason,onChange:s=>g(x(u({},c),{reason:s.target.value})),placeholder:"For example: User forgot their password",className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2.5",required:!0}),(0,e.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Saved in the activity log. The password itself is never recorded."})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{htmlFor:"adminCurrentPassword",className:"block text-sm font-semibold text-gray-900",children:"Your current password"}),(0,e.jsx)("input",{id:"adminCurrentPassword",type:"password",autoComplete:"current-password",value:c.currentPassword,onChange:s=>g(x(u({},c),{currentPassword:s.target.value})),className:"mt-1 block w-full rounded-md border border-gray-300 px-3 py-2.5",required:!0}),(0,e.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Confirms that it is really you making this change."})]}),(0,e.jsxs)("label",{className:"flex items-start gap-2 rounded-md bg-amber-50 px-3 py-3 text-sm text-amber-950",children:[(0,e.jsx)("input",{type:"checkbox",className:"mt-0.5 rounded border-amber-300 text-ekc-blue focus:ring-ekc-blue",checked:c.requireChange,onChange:s=>g(x(u({},c),{requireChange:s.target.checked}))}),(0,e.jsxs)("span",{children:[(0,e.jsx)("strong",{className:"font-semibold",children:"Require a private password at next sign-in"}),(0,e.jsx)("br",{}),"Recommended for forgotten-password resets."]})]}),(0,e.jsxs)("div",{className:"flex justify-end gap-3 pt-2",children:[(0,e.jsx)("button",{type:"button",onClick:K,disabled:P,className:"rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-semibold text-gray-700 hover:bg-gray-50 disabled:opacity-60",children:"Cancel"}),(0,e.jsx)("button",{type:"submit",disabled:P,className:"rounded-md bg-ekc-blue px-4 py-2 text-sm font-semibold text-white hover:bg-opacity-85 disabled:opacity-60",children:P?"Resetting\u2026":"Reset password"})]})]})]})})})})]})})]}):(0,e.jsxs)("main",{className:"ml-64 p-6",children:[(0,e.jsx)("h1",{className:"mb-2 text-2xl font-semibold",children:"User Management"}),(0,e.jsx)("p",{className:"text-gray-600",children:"Superadmins only. Your account does not have access."})]})}}}]);
2
3//# sourceMappingURL=5534.1d6e8ac8.chunk.js.map

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.