fix: update
This commit is contained in:
@@ -13,5 +13,7 @@ export const cnb = useContextKey<CNB>('cnb', () => {
|
|||||||
})
|
})
|
||||||
export const appId = nanoid();
|
export const appId = nanoid();
|
||||||
export const app = useContextKey<App>('app', () => {
|
export const app = useContextKey<App>('app', () => {
|
||||||
return new App()
|
return new App({
|
||||||
|
appId
|
||||||
|
})
|
||||||
})
|
})
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
import { app, appId } from '@/agent/app.ts';
|
import { app, appId } from '../app.ts';
|
||||||
import './user/check.ts'
|
import './user/check.ts'
|
||||||
|
import { isEqual } from 'es-toolkit'
|
||||||
|
/**
|
||||||
|
* 验证上下文中的 App ID 是否与指定的 App ID 匹配
|
||||||
|
* @param {any} ctx - 上下文对象,可能包含 appId 属性
|
||||||
|
* @param {string} appId - 需要验证的目标 App ID
|
||||||
|
* @returns {boolean} 如果 ctx 中包含 appId 且匹配则返回 true,否则返回 false
|
||||||
|
* @throws {Error} 如果 ctx 中包含 appId 但不匹配,则抛出 403 错误
|
||||||
|
*/
|
||||||
const checkAppId = (ctx: any, appId: string) => {
|
const checkAppId = (ctx: any, appId: string) => {
|
||||||
const _appId = ctx?.appId;
|
const _appId = ctx?.app?.appId;
|
||||||
if (_appId) {
|
if (_appId) {
|
||||||
if (_appId !== appId) {
|
if (_appId !== appId) {
|
||||||
ctx.throw(403, 'Invalid App ID');
|
ctx.throw(403, 'Invalid App ID');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { app, cnb } from '@/agent/app.ts';
|
import { app, cnb } from '../../app.ts';
|
||||||
|
|
||||||
app.route({
|
app.route({
|
||||||
path: 'cnb',
|
path: 'cnb',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { app, cnb } from '@/agent/app.ts';
|
import { app, cnb } from '../../app.ts';
|
||||||
|
|
||||||
|
|
||||||
app.route({
|
app.route({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { app, cnb } from '@/agent/app.ts';
|
import { app, cnb } from '../../app.ts';
|
||||||
|
|
||||||
app.route({
|
app.route({
|
||||||
path: 'cnb',
|
path: 'cnb',
|
||||||
|
|||||||
Reference in New Issue
Block a user