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