tachybase_todo/packages/plugin-ui-schema-storage/src/server-hooks/hooks/bind-menu-to-role.ts
chenos f791d43716
feat: acl provider (#279)
* feat: acl provider

* feat: menu server hook

* feat: improve code

* fix: fields filter
2022-04-10 19:22:39 +08:00

16 lines
412 B
TypeScript

export async function bindMenuToRole({ schemaInstance, db, options }) {
const { transaction } = options;
const addNewMenuRoles = await db.getRepository('roles').find({
filter: {
allowNewMenu: true,
},
});
for (const role of addNewMenuRoles) {
await db.getRepository('roles.menuUiSchemas', role.get('name')).add({
tk: schemaInstance.get('x-uid'),
transaction,
});
}
}