后台:权限
This commit is contained in:
@@ -2,8 +2,8 @@ import { GMUserModel } from '@db/GMUser';
|
||||
import { GMUserGroupModel } from '@db/GMUserGroup'
|
||||
import { GMGroupModel } from '@db/GMGroup'
|
||||
import { GMRecordModel } from '@db/GMRecord'
|
||||
import { ApiModel } from '@db/Api';
|
||||
import { STATUS } from '@consts';
|
||||
import { gameData } from 'app/pubUtils/data';
|
||||
|
||||
module.exports = () => {
|
||||
return async function tokenParser(ctx, next) {
|
||||
@@ -20,18 +20,18 @@ module.exports = () => {
|
||||
return;
|
||||
}
|
||||
const url = ctx.request.url;
|
||||
let apiResult = await ApiModel.getApi(url);
|
||||
if(!apiResult) {
|
||||
let dicApi = gameData.apiByUrl.get(url);
|
||||
if(!dicApi) {
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.GM_MISS_API);
|
||||
return;
|
||||
}
|
||||
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, 1);
|
||||
let userGroups = await GMUserGroupModel.getUserGroupByUid(user.uid, ctx.app.config.realEnv);
|
||||
let flag = 0;
|
||||
for(let userGroup of userGroups) {
|
||||
let { groupId } = userGroup;
|
||||
let group = await GMGroupModel.getGroupById(groupId);
|
||||
if(group) {
|
||||
if(group.apis.includes(apiResult.apiId)) {
|
||||
if(group.apis.includes(dicApi.id)) {
|
||||
flag = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user