import{u as j,r as l,a as w,j as e,B as d,aE as g}from"./index-BLjtKp_X.js";import{C as y,f as P}from"./auth-CY09lDKH.js";import{R as N,e as I}from"./encrypt-BxrsaDkR.js";import{H as E}from"./head-CXYXhTUP.js";import{F as t}from"./index-CM8WjZyp.js";import{I as i,R as h}from"./LockOutlined-Cb8Fzp1E.js";const q=()=>{const{t:s}=j(),[n,a]=l.useState(""),m=w();l.useEffect(()=>{n&&setTimeout(()=>a(""),3e3)},[n]);function u(r){if(r.password!==r.password2){a(s("auth.differentPassword"));return}if(!c(r.username)){a(s("auth.illegalUsername"));return}if(!c(r.password)){a("auth.illegalPassword");return}const o=r.username,p=I(r.password);P(o,p).then(f=>{if(f.code!==0){a(s("auth.error"));return}g(),m("/auth/login",{replace:!0})}).catch(()=>{a(s("auth.error"))})}function c(r){return!/['"\\/]/.test(r)}function x(){window.location.replace("/")}return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:s("head.changePassword")}),e.jsxs("div",{className:"flex h-screen w-screen flex-col items-center justify-center space-y-5",children:[e.jsx("h2",{className:"text-xl font-semibold text-neutral-100",children:s("auth.changePassword")}),e.jsxs(t,{style:{minWidth:300,maxWidth:500},initialValues:{remember:!0},onFinish:u,children:[e.jsx(t.Item,{name:"username",rules:[{required:!0,message:s("auth.noEmptyUsername"),min:1}],children:e.jsx(i,{prefix:e.jsx(N,{}),placeholder:s("auth.placeholderUsername")})}),e.jsx(t.Item,{name:"password",rules:[{required:!0,message:s("auth.noEmptyPassword"),min:1}],children:e.jsx(i,{prefix:e.jsx(h,{}),type:"password",placeholder:s("auth.placeholderPassword")})}),e.jsx(t.Item,{name:"password2",rules:[{required:!0,message:s("auth.noEmptyPassword"),min:1}],children:e.jsx(i,{prefix:e.jsx(h,{}),type:"password",placeholder:s("auth.placeholderPassword2")})}),e.jsx("span",{className:"text-red-500",children:n}),e.jsx(t.Item,{children:e.jsxs("div",{className:"flex w-full space-x-2",children:[e.jsx(d,{type:"primary",htmlType:"submit",className:"w-1/2",children:s("auth.ok")}),e.jsx(d,{className:"w-1/2",onClick:x,children:s("auth.cancel")})]})})]}),e.jsx(y,{children:e.jsxs("div",{className:"flex w-[450px] flex-col",children:[e.jsx("div",{children:s("auth.tips.change1")}),e.jsxs("ul",{className:"list-outside list-decimal",children:[e.jsx("li",{children:s("auth.tips.change2")}),e.jsx("li",{children:s("auth.tips.change3")})]}),e.jsx("div",{className:"text-red-500",children:s("auth.tips.change4")})]})})]})]})};export{q as Password};
