mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
样式调整基本完成
This commit is contained in:
parent
db8be98230
commit
4f71182fd6
@ -3,13 +3,17 @@ import { redirect } from "next/navigation";
|
|||||||
// import { getSession } from "@/lib/auth";
|
// import { getSession } from "@/lib/auth";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { Button, Checkbox, Form, Input } from "antd";
|
import { Button, Checkbox, Form, Input } from "antd";
|
||||||
|
import { LockOutlined } from "@ant-design/icons";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
type LoginType = "phone" | "account";
|
type LoginType = "phone" | "account";
|
||||||
|
|
||||||
export default function SetPasswordPage() {
|
export default function SetPasswordPage() {
|
||||||
const { data: session, status } = useSession();
|
const { data: session, status } = useSession();
|
||||||
|
|
||||||
|
const [setPasswordForm] = Form.useForm();
|
||||||
// if (typeof window !== "undefined" && loading) return null;
|
// if (typeof window !== "undefined" && loading) return null;
|
||||||
console.log("2222222", session);
|
// console.log("2222222", session);
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
if (!session?.user?.hasPassword) {
|
if (!session?.user?.hasPassword) {
|
||||||
}
|
}
|
||||||
@ -18,18 +22,99 @@ export default function SetPasswordPage() {
|
|||||||
// }
|
// }
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>Signed in as {}</p>
|
{/*<p>Signed in as {}</p>*/}
|
||||||
<div>需要设置一个密码</div>
|
{/*<div>需要设置一个密码</div>*/}
|
||||||
<Form></Form>
|
<div className="mx-auto mt-4 w-11/12 max-w-xs sm:w-full">
|
||||||
|
<Form
|
||||||
<Button
|
autoComplete="off"
|
||||||
onClick={(e) => {
|
form={setPasswordForm}
|
||||||
e.preventDefault();
|
id="set-password-form"
|
||||||
window.location.href = "/";
|
layout="vertical"
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
跳过
|
<Form.Item
|
||||||
</Button>
|
name="user[old_password]"
|
||||||
|
label="Old password"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (!value) {
|
||||||
|
return Promise.reject(new Error("请填写该字段"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
prefix={<LockOutlined className="site-form-item-icon" />}
|
||||||
|
type="password"
|
||||||
|
autoComplete="current-password"
|
||||||
|
id="user_old_password"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="user[password]"
|
||||||
|
label="New password"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
min: 6,
|
||||||
|
message: "Make sure it's at least 6 characters",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (!value) {
|
||||||
|
return Promise.reject(new Error("请填写该字段"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
prefix={<LockOutlined className="site-form-item-icon" />}
|
||||||
|
type="password"
|
||||||
|
autoComplete="off"
|
||||||
|
id="user_new_password"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="user[password_confirmation]"
|
||||||
|
label="Confirm new password"
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
validator: async (_, value) => {
|
||||||
|
if (!value) {
|
||||||
|
return Promise.reject(new Error("请填写该字段"));
|
||||||
|
}
|
||||||
|
const new_password =
|
||||||
|
setPasswordForm.getFieldValue("user[password]");
|
||||||
|
if (value !== new_password) {
|
||||||
|
return Promise.reject(new Error("密码不一致"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
prefix={<LockOutlined className="site-form-item-icon" />}
|
||||||
|
type="password"
|
||||||
|
autoComplete="new-password"
|
||||||
|
aria-autocomplete="list"
|
||||||
|
id="user_confirm_new_password"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item>
|
||||||
|
<a href="/" className="mr-2.5 align-bottom">
|
||||||
|
暂时跳过
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="short-width-button w-full rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</button>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
import { UserOutlined, MailOutlined } from "@ant-design/icons";
|
import { UserOutlined, MailOutlined } from "@ant-design/icons";
|
||||||
import type { FormProps, TabsProps } from "antd";
|
import type { FormProps, TabsProps } from "antd";
|
||||||
import { SignInOptions } from "next-auth/react";
|
import { SignInOptions } from "next-auth/react";
|
||||||
|
import { getSession } from "next-auth/react";
|
||||||
|
|
||||||
export default function UserLoginCore() {
|
export default function UserLoginCore() {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@ -66,10 +67,20 @@ export default function UserLoginCore() {
|
|||||||
// 如果没有密码,且登录成功了,说明需要设置密码
|
// 如果没有密码,且登录成功了,说明需要设置密码
|
||||||
let result_url =
|
let result_url =
|
||||||
result?.url && result.url.includes("verify") ? result.url : "/";
|
result?.url && result.url.includes("verify") ? result.url : "/";
|
||||||
|
|
||||||
|
// 手动获取一遍session
|
||||||
|
getSession()
|
||||||
|
.then((value) => {
|
||||||
|
// @ts-expect-error
|
||||||
|
if (!value?.user?.hasPassword) {
|
||||||
if (result_url === "/") {
|
if (result_url === "/") {
|
||||||
result_url = "/login/set-password";
|
result_url = "/login/set-password";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
window.location.href = result_url;
|
window.location.href = result_url;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
switch (result.error) {
|
switch (result.error) {
|
||||||
case "AccessDenied":
|
case "AccessDenied":
|
||||||
|
@ -99,3 +99,30 @@ input {
|
|||||||
#user-admin-table-pop_confirm input:-webkit-autofill {
|
#user-admin-table-pop_confirm input:-webkit-autofill {
|
||||||
transition: background-color 5000s ease-in-out 0s;
|
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;
|
||||||
|
}
|
||||||
|
@ -45,10 +45,10 @@ export default async function middleware(req: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VerifiedNeedSetPassword(path, session as CUS_JWT)) {
|
// if (VerifiedNeedSetPassword(path, session as CUS_JWT)) {
|
||||||
console.log('-0-0-- 需要修改密码', )
|
// console.log('-0-0-- 需要修改密码', )
|
||||||
// return NextResponse.redirect(new URL("/login/set-password", req.url))
|
// // return NextResponse.redirect(new URL("/login/set-password", req.url))
|
||||||
}
|
// }
|
||||||
|
|
||||||
return NextResponse.next()
|
return NextResponse.next()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user