mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix: test
This commit is contained in:
parent
65eb91bef3
commit
b80b6702ab
@ -170,7 +170,7 @@ export class ACL extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getRoles(names: string[]): ACLRole[] {
|
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) {
|
removeRole(name: string) {
|
||||||
|
@ -39,7 +39,7 @@ export async function checkAction(ctx, next) {
|
|||||||
|
|
||||||
let roles = ctx.app.acl.getRoles(currentRoles);
|
let roles = ctx.app.acl.getRoles(currentRoles);
|
||||||
if (!roles.length) {
|
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);
|
roles = ctx.app.acl.getRoles(currentRoles);
|
||||||
}
|
}
|
||||||
const availableActions = ctx.app.acl.getAvailableActions();
|
const availableActions = ctx.app.acl.getAvailableActions();
|
||||||
|
@ -12,9 +12,7 @@ import _ from 'lodash';
|
|||||||
export function mergeRole(roles) {
|
export function mergeRole(roles) {
|
||||||
const result: Record<string, any> = {
|
const result: Record<string, any> = {
|
||||||
roles: [],
|
roles: [],
|
||||||
strategy: {
|
strategy: {},
|
||||||
actions: [],
|
|
||||||
},
|
|
||||||
actions: null,
|
actions: null,
|
||||||
snippets: [],
|
snippets: [],
|
||||||
resources: null,
|
resources: null,
|
||||||
@ -35,6 +33,9 @@ function mergeRoleNames(sourceRoleNames, newRoleName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mergeRoleStrategy(sourceStrategy, newStrategy) {
|
function mergeRoleStrategy(sourceStrategy, newStrategy) {
|
||||||
|
if (!newStrategy) {
|
||||||
|
return sourceStrategy;
|
||||||
|
}
|
||||||
const actions = sourceStrategy.actions.concat(newStrategy.actions);
|
const actions = sourceStrategy.actions.concat(newStrategy.actions);
|
||||||
return {
|
return {
|
||||||
...sourceStrategy,
|
...sourceStrategy,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user