diff --git a/app/app/(auth)/login/set-password/page.tsx b/app/app/(auth)/login/set-password/page.tsx index f0fe2ff14..b8513e220 100644 --- a/app/app/(auth)/login/set-password/page.tsx +++ b/app/app/(auth)/login/set-password/page.tsx @@ -3,13 +3,17 @@ import { redirect } from "next/navigation"; // import { getSession } from "@/lib/auth"; import { useSession } from "next-auth/react"; import { Button, Checkbox, Form, Input } from "antd"; +import { LockOutlined } from "@ant-design/icons"; +import React from "react"; type LoginType = "phone" | "account"; export default function SetPasswordPage() { const { data: session, status } = useSession(); + + const [setPasswordForm] = Form.useForm(); // if (typeof window !== "undefined" && loading) return null; - console.log("2222222", session); + // console.log("2222222", session); // @ts-expect-error if (!session?.user?.hasPassword) { } @@ -18,18 +22,99 @@ export default function SetPasswordPage() { // } return ( <> -

Signed in as {}

-
需要设置一个密码
-
+ {/*

Signed in as {}

*/} + {/*
需要设置一个密码
*/} +
+
+ { + if (!value) { + return Promise.reject(new Error("请填写该字段")); + } + }, + }, + ]} + > + } + type="password" + autoComplete="current-password" + id="user_old_password" + /> + + { + if (!value) { + return Promise.reject(new Error("请填写该字段")); + } + }, + }, + ]} + > + } + type="password" + autoComplete="off" + id="user_new_password" + /> + + { + if (!value) { + return Promise.reject(new Error("请填写该字段")); + } + const new_password = + setPasswordForm.getFieldValue("user[password]"); + if (value !== new_password) { + return Promise.reject(new Error("密码不一致")); + } + }, + }, + ]} + > + } + type="password" + autoComplete="new-password" + aria-autocomplete="list" + id="user_confirm_new_password" + /> + - + + + 暂时跳过 + + + +
+
); } diff --git a/app/app/(auth)/login/user-login-core.tsx b/app/app/(auth)/login/user-login-core.tsx index beff8d709..5cb80f36b 100644 --- a/app/app/(auth)/login/user-login-core.tsx +++ b/app/app/(auth)/login/user-login-core.tsx @@ -14,6 +14,7 @@ import { import { UserOutlined, MailOutlined } from "@ant-design/icons"; import type { FormProps, TabsProps } from "antd"; import { SignInOptions } from "next-auth/react"; +import { getSession } from "next-auth/react"; export default function UserLoginCore() { const [loading, setLoading] = useState(false); @@ -66,10 +67,20 @@ export default function UserLoginCore() { // 如果没有密码,且登录成功了,说明需要设置密码 let result_url = result?.url && result.url.includes("verify") ? result.url : "/"; - if (result_url === "/") { - result_url = "/login/set-password"; - } - window.location.href = result_url; + + // 手动获取一遍session + getSession() + .then((value) => { + // @ts-expect-error + if (!value?.user?.hasPassword) { + if (result_url === "/") { + result_url = "/login/set-password"; + } + } + }) + .finally(() => { + window.location.href = result_url; + }); } else { switch (result.error) { case "AccessDenied": diff --git a/app/app/login.scss b/app/app/login.scss index 2e1dbccd0..d2519df83 100644 --- a/app/app/login.scss +++ b/app/app/login.scss @@ -99,3 +99,30 @@ input { #user-admin-table-pop_confirm input:-webkit-autofill { transition: background-color 5000s ease-in-out 0s; } + +#set-password-form input:-webkit-autofill { + transition: background-color 5000s ease-in-out 0s; +} + + +/* 提交按钮特定宽度 */ + +.short-width-button { + width: auto !important; +} + +//#set-password-form .ant-form-item { +// margin-top: auto !important; +// margin-bottom: auto !important; +//} + +#set-password-form .ant-form-item .ant-col label { + font-weight: 600; +} +#set-password-form .ant-btn { + font-weight: 600; +} + +#set-password-form { + text-align: right !important; +} diff --git a/middleware.ts b/middleware.ts index 6c25db144..1a8c7ff79 100644 --- a/middleware.ts +++ b/middleware.ts @@ -45,10 +45,10 @@ export default async function middleware(req: NextRequest) { ); } - if (VerifiedNeedSetPassword(path, session as CUS_JWT)) { - console.log('-0-0-- 需要修改密码', ) - // return NextResponse.redirect(new URL("/login/set-password", req.url)) - } + // if (VerifiedNeedSetPassword(path, session as CUS_JWT)) { + // console.log('-0-0-- 需要修改密码', ) + // // return NextResponse.redirect(new URL("/login/set-password", req.url)) + // } return NextResponse.next() }