feat: integrate Drizzle ORM and SQLite for authentication

This commit is contained in:
2025-06-18 16:15:49 +08:00
parent 6652953b1a
commit bc81e4d6fe
13 changed files with 1024 additions and 37 deletions

View File

@ -1,21 +1,23 @@
import { defineEventHandler, readBody, setResponseStatus } from 'h3';
import { defineEventHandler, readBody, setResponseStatus, useRuntimeConfig } from 'h3';
export default defineEventHandler(async (event) => {
const body = await readBody(event);
const { password } = body;
const config = useRuntimeConfig(event);
if (!password) {
setResponseStatus(event, 400);
return { message: '请填写密码' };
}
// TODO: Replace with a more secure admin authentication method
if (password === 'adminpassword') {
return {
message: '管理员登录成功!',
};
} else {
const adminPassword = config.adminPassword;
if (!adminPassword || password !== adminPassword) {
setResponseStatus(event, 401);
return { message: '密码错误' };
}
return {
message: '管理员登录成功!',
};
});