update
This commit is contained in:
36
agent/routes/index.ts
Normal file
36
agent/routes/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { app, appId } from '@/agent/app.ts';
|
||||
import './user/check.ts'
|
||||
|
||||
const checkAppId = (ctx: any, appId: string) => {
|
||||
const _appId = ctx?.appId;
|
||||
if (_appId) {
|
||||
if (_appId !== appId) {
|
||||
ctx.throw(403, 'Invalid App ID');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!app.hasRoute('auth')) {
|
||||
app.route({
|
||||
id: 'auth',
|
||||
path: 'auth',
|
||||
}).define(async (ctx) => {
|
||||
// ctx.body = 'Auth Route';
|
||||
if (checkAppId(ctx, appId)) {
|
||||
return;
|
||||
}
|
||||
}).addTo(app);
|
||||
|
||||
app.route({
|
||||
id: 'admin-auth',
|
||||
path: 'admin-auth',
|
||||
middleware: ['auth'],
|
||||
}).define(async (ctx) => {
|
||||
// ctx.body = 'Admin Auth Route';
|
||||
if (checkAppId(ctx, appId)) {
|
||||
return;
|
||||
}
|
||||
}).addTo(app);
|
||||
}
|
||||
Reference in New Issue
Block a user