security: server-owned audit logs + fullscreen custom pages

Port upstream PR #22 + Lite style updates:
- lib/audit.js: server-side logAudit(req, action, userId), records
  IP from x-forwarded-for / cf-connecting-ip
- login/register/create_post/create_reply record server-side
- Remove client logEvent calls (AppProvider/NewPost/ReplyList)
- Remove forgeable POST /api/event-logs endpoint
- CustomPage: fullscreen immersive (fixed, 100vh-nav, mobile 56px
  nav offset) matching upstream Lite
This commit is contained in:
lezi-fun committed 2026-08-12 09:06:50 +08:00
1 parent 45ace3ba75
commit b9d6ca5da8
11 files changed
+73 -24

No files matched your search

+3
View File
@@ -3,6 +3,7 @@ import bcrypt from 'bcryptjs';
import jwt from 'jsonwebtoken';
import pool from '@/lib/db';
import { JWT_SECRET } from '@/lib/auth';
import { logAudit } from '@/lib/audit';
export async function POST(req) {
const { email, password } = await req.json();
@@ -24,6 +25,8 @@ export async function POST(req) {
JWT_SECRET,
{ expiresIn: '7d' }
);
// 服务端审计:登录成功
await logAudit(req, 'login', user.id);
return Response.json({
token,
user: {
+3
View File
@@ -2,6 +2,7 @@
import bcrypt from 'bcryptjs';
import pool from '@/lib/db';
import { verifyCaptcha } from '@/lib/captcha';
import { logAudit } from '@/lib/audit';
export async function POST(req) {
const { email, password, username, captcha_id, captcha_answer, captcha_sig } = await req.json();
@@ -30,6 +31,8 @@ export async function POST(req) {
[email, hash, username, avatar, role]
);
// 服务端审计:注册成功
await logAudit(req, 'register', r.rows[0].id);
return Response.json({
user: r.rows[0],
message: isFirstUser ? '你是第一个用户,已自动设为管理员!' : '注册成功',