fix: test

This commit is contained in:
霍世杰 2025-02-21 11:29:43 +08:00
parent 65eb91bef3
commit b80b6702ab
3 changed files with 6 additions and 5 deletions

View File

@ -170,7 +170,7 @@ export class ACL extends EventEmitter {
}
getRoles(names: string[]): ACLRole[] {
return names.map((name) => this.getRole(name));
return names.map((name) => this.getRole(name)).filter((x) => Boolean(x));
}
removeRole(name: string) {

View File

@ -39,7 +39,7 @@ export async function checkAction(ctx, next) {
let roles = ctx.app.acl.getRoles(currentRoles);
if (!roles.length) {
await ctx.app.emitAsync('acl:writeRoleToACL', roleInstances);
await Promise.all(roleInstances.map((x) => ctx.app.emitAsync('acl:writeRoleToACL', x)));
roles = ctx.app.acl.getRoles(currentRoles);
}
const availableActions = ctx.app.acl.getAvailableActions();

View File

@ -12,9 +12,7 @@ import _ from 'lodash';
export function mergeRole(roles) {
const result: Record<string, any> = {
roles: [],
strategy: {
actions: [],
},
strategy: {},
actions: null,
snippets: [],
resources: null,
@ -35,6 +33,9 @@ function mergeRoleNames(sourceRoleNames, newRoleName) {
}
function mergeRoleStrategy(sourceStrategy, newStrategy) {
if (!newStrategy) {
return sourceStrategy;
}
const actions = sourceStrategy.actions.concat(newStrategy.actions);
return {
...sourceStrategy,