tachybase_todo/packages/plugin-acl/src/model/RoleModel.ts
ChengLei Shao 000587380b
fix: postgres sort with appends issue (#198)
* fix: postgres sort with appends issue

* fix: role menus api error

* feat: add exists params in roles.collections api

* refactor: remove uid field on uiSchemas table

* test: toggle role menus

* fix: plugin-acl test

* feat: sync data to acl before app start

* fix: mysql ui-schema sql compatibility

* feat: writeRolesToACL in plugin-acl
2022-02-20 01:23:04 +08:00

22 lines
509 B
TypeScript

import { Model } from '@nocobase/database';
import { ACL } from '@nocobase/acl';
export class RoleModel extends Model {
writeToAcl(options: { acl: ACL }) {
const { acl } = options;
const roleName = this.get('name') as string;
let role = acl.getRole(roleName);
if (!role) {
role = acl.define({
role: roleName,
});
}
role.setStrategy({
...((this.get('strategy') as object) || {}),
allowConfigure: this.get('allowConfigure') as boolean,
});
}
}