Files
forumlify/app/api/auth/me/route.js
lezi-fun 581925ad7d feat: user signature (设置页编辑 + 帖子底部显示)
- schema: users.signature column (upstream aligned)
- API: posts query JOIN signature, /auth/me returns signature, PUT /users/:id updates signature
- Settings: signature textarea (Markdown hint), saved with profile
- PostDetail: signature shown under post content with divider
- README: remove upstream DB schema note (fixed upstream)
2026-08-10 14:45:50 +08:00

23 lines
633 B
JavaScript

// GET /api/auth/me
import pool from '@/lib/db';
import { getUser } from '@/lib/auth';
export async function GET(req) {
const user = getUser(req);
if (!user) {
return Response.json({ error: '请先登录' }, { status: 401 });
}
try {
const r = await pool.query(
'SELECT id, username, avatar_url, bio, signature, role, created_at FROM users WHERE id = $1',
[user.id]
);
if (!r.rows[0]) {
return Response.json({ error: '用户不存在' }, { status: 404 });
}
return Response.json(r.rows[0]);
} catch {
return Response.json({ error: '服务器错误' }, { status: 500 });
}
}