fix: root & anonymous roles
This commit is contained in:
parent
9526ce13f2
commit
b1decb359b
@ -57,7 +57,10 @@ export const roleSchema: ISchema = {
|
|||||||
action: 'list',
|
action: 'list',
|
||||||
params: {
|
params: {
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
filter: {},
|
filter: {
|
||||||
|
'name.$ne': 'root',
|
||||||
|
},
|
||||||
|
showAnonymous: true,
|
||||||
sort: ['createdAt'],
|
sort: ['createdAt'],
|
||||||
appends: [],
|
appends: [],
|
||||||
},
|
},
|
||||||
|
@ -304,15 +304,18 @@ export class PluginACL extends Plugin {
|
|||||||
this.app.acl.skip('*', '*', (ctx) => {
|
this.app.acl.skip('*', '*', (ctx) => {
|
||||||
return ctx.state.currentRole === 'root';
|
return ctx.state.currentRole === 'root';
|
||||||
});
|
});
|
||||||
// root role
|
|
||||||
this.app.resourcer.use(async (ctx, next) => {
|
this.app.resourcer.use(async (ctx, next) => {
|
||||||
const { actionName, resourceName } = ctx.action.params;
|
const { actionName, resourceName, params } = ctx.action;
|
||||||
|
const { showAnonymous } = params || {};
|
||||||
if (actionName === 'list' && resourceName === 'roles') {
|
if (actionName === 'list' && resourceName === 'roles') {
|
||||||
ctx.action.mergeParams({
|
if (!showAnonymous) {
|
||||||
filter: {
|
ctx.action.mergeParams({
|
||||||
'name.$ne': 'root',
|
filter: {
|
||||||
},
|
'name.$ne': 'anonymous',
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await next();
|
await next();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user