feat: add admin account, add refresh log

This commit is contained in:
shinya
2025-07-04 20:50:12 +08:00
parent 029ce7335c
commit 44ce8241c6
5 changed files with 131 additions and 50 deletions

View File

@@ -44,6 +44,14 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: '密码不能为空' }, { status: 400 });
}
// 可能是管理员,直接读环境变量
if (
username === process.env.USERNAME &&
password === process.env.PASSWORD
) {
return NextResponse.json({ ok: true });
}
// 校验用户密码
try {
const pass = await db.verifyUser(username, password);

View File

@@ -34,6 +34,11 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: '密码不能为空' }, { status: 400 });
}
// 检查是否和管理员重复
if (username === process.env.USERNAME) {
return NextResponse.json({ error: '用户已存在' }, { status: 400 });
}
try {
// 检查用户是否已存在
const exist = await db.checkUserExist(username);