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:
1 parent
45ace3ba75
commit
b9d6ca5da8
11 files changed
+73
-24
No files matched your search
@@ -181,8 +181,7 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
try {
|
||||
const user = await API.getMe();
|
||||
setCurrentUser(user);
|
||||
API.logEvent('login').catch(() => {});
|
||||
} catch {
|
||||
} catch {
|
||||
setToken(null);
|
||||
}
|
||||
}
|
||||
@@ -395,7 +394,6 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
const result = await API.login(email, password);
|
||||
if (result.user) {
|
||||
setCurrentUser(result.user);
|
||||
API.logEvent('login').catch(() => {});
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
@@ -405,7 +403,6 @@ export default function AppProvider({ children, cachedName = '' }) {
|
||||
const loginResult = await API.login(email, password);
|
||||
if (loginResult.user) {
|
||||
setCurrentUser(loginResult.user);
|
||||
API.logEvent('register').catch(() => {});
|
||||
}
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
@@ -49,7 +49,7 @@ export default function CustomPage({ pageName }) {
|
||||
</html>`;
|
||||
|
||||
return (
|
||||
<div style={{ padding: '84px 32px 40px', background: 'var(--bg)', minHeight: '100vh' }}>
|
||||
<div className="custom-page-container" style={{ padding: '84px 32px 40px', background: 'var(--bg)', minHeight: '100vh' }}>
|
||||
<iframe
|
||||
style={{ width: '100%', minHeight: '70vh', border: 'none', borderRadius: 8, background: 'var(--surface)' }}
|
||||
sandbox="allow-scripts allow-modals allow-same-origin"
|
||||
|
||||
@@ -71,7 +71,6 @@ export default function NewPost() {
|
||||
try {
|
||||
// 答案由服务端 HMAC 校验
|
||||
await API.createPost(title.trim() || '无标题', content.trim(), images, { id: captcha.id, answer: captchaInput.trim(), sig: captcha.sig });
|
||||
API.logEvent('create_post').catch(() => {});
|
||||
toast('发布成功', 'success');
|
||||
navigate('feed');
|
||||
refresh();
|
||||
|
||||
@@ -52,7 +52,6 @@ export default function ReplyList({ postId, onRefresh }) {
|
||||
try {
|
||||
// 答案由服务端 HMAC 校验
|
||||
await API.createReply(postId, content.trim(), { id: captcha.id, answer: captchaInput.trim(), sig: captcha.sig }, replyTo);
|
||||
API.logEvent('create_reply').catch(() => {});
|
||||
setContent('');
|
||||
setCaptchaInput('');
|
||||
setReplyTo(null);
|
||||
|
||||
Reference in new issue
Block a user