优化用户代理逻辑,移除非管理员用户的敏感数据
This commit is contained in:
@@ -5,6 +5,7 @@ import { App } from '@kevisual/router';
|
|||||||
import { logger } from '../logger.ts';
|
import { logger } from '../logger.ts';
|
||||||
import { getLoginUser } from '@/modules/auth.ts';
|
import { getLoginUser } from '@/modules/auth.ts';
|
||||||
import { createStudioAppListHtml } from '../html/studio-app-list/index.ts';
|
import { createStudioAppListHtml } from '../html/studio-app-list/index.ts';
|
||||||
|
import { omit } from 'es-toolkit';
|
||||||
|
|
||||||
type ProxyOptions = {
|
type ProxyOptions = {
|
||||||
createNotFoundPage: (msg?: string) => any;
|
createNotFoundPage: (msg?: string) => any;
|
||||||
@@ -74,9 +75,12 @@ export const UserV1Proxy = async (req: IncomingMessage, res: ServerResponse, opt
|
|||||||
res.end(await html);
|
res.end(await html);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// const { token, cookies, ...rest } = data;
|
let message: any = data;
|
||||||
const value = await client.sendData(data, {
|
if (!isAdmin) {
|
||||||
state: { tokenUser: loginUser.tokenUser },
|
message = omit(data, ['token', 'cookies']);
|
||||||
|
}
|
||||||
|
const value = await client.sendData(message, {
|
||||||
|
state: { tokenUser: omit(loginUser.tokenUser, ['oauthExpand']) },
|
||||||
});
|
});
|
||||||
if (value) {
|
if (value) {
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
|
|||||||
Reference in New Issue
Block a user