优化用户代理逻辑,移除非管理员用户的敏感数据
This commit is contained in:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user