fix(acl): sync role strategy after create (#1565)
Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1565
This commit is contained in:
parent
2e15125445
commit
943c4cd954
@ -253,6 +253,20 @@ export class PluginACL extends Plugin {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 只有初始化的时候才执行
|
||||||
|
this.app.db.on('roles.afterCreateWithAssociations', async (model, options) => {
|
||||||
|
const { transaction } = options;
|
||||||
|
await this.app.db.getRepository('dataSourcesRoles').updateOrCreate({
|
||||||
|
values: {
|
||||||
|
roleName: model.get('name'),
|
||||||
|
dataSourceKey: 'main',
|
||||||
|
strategy: model.get('strategy'),
|
||||||
|
},
|
||||||
|
filterKeys: ['roleName', 'dataSourceKey'],
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this.app.db.on('roles.afterSaveWithAssociations', async (model, options) => {
|
this.app.db.on('roles.afterSaveWithAssociations', async (model, options) => {
|
||||||
const { transaction } = options;
|
const { transaction } = options;
|
||||||
|
|
||||||
@ -265,7 +279,6 @@ export class PluginACL extends Plugin {
|
|||||||
values: {
|
values: {
|
||||||
roleName: model.get('name'),
|
roleName: model.get('name'),
|
||||||
dataSourceKey: 'main',
|
dataSourceKey: 'main',
|
||||||
strategy: model.get('strategy'),
|
|
||||||
},
|
},
|
||||||
filterKeys: ['roleName', 'dataSourceKey'],
|
filterKeys: ['roleName', 'dataSourceKey'],
|
||||||
transaction,
|
transaction,
|
||||||
|
Loading…
Reference in New Issue
Block a user