优化用户代理逻辑,移除非管理员用户的敏感数据

This commit is contained in:
2026-02-05 04:50:54 +08:00
parent a51d04341e
commit f616045625

View File

@@ -5,6 +5,7 @@ import { App } from '@kevisual/router';
import { logger } from '../logger.ts';
import { getLoginUser } from '@/modules/auth.ts';
import { createStudioAppListHtml } from '../html/studio-app-list/index.ts';
import { omit } from 'es-toolkit';
type ProxyOptions = {
createNotFoundPage: (msg?: string) => any;
@@ -74,9 +75,12 @@ export const UserV1Proxy = async (req: IncomingMessage, res: ServerResponse, opt
res.end(await html);
return true;
}
// const { token, cookies, ...rest } = data;
const value = await client.sendData(data, {
state: { tokenUser: loginUser.tokenUser },
let message: any = data;
if (!isAdmin) {
message = omit(data, ['token', 'cookies']);
}
const value = await client.sendData(message, {
state: { tokenUser: omit(loginUser.tokenUser, ['oauthExpand']) },
});
if (value) {
res.writeHead(200, { 'Content-Type': 'application/json' });