permission change length != 0
This commit is contained in:
parent
d24785cd69
commit
75fb556796
2 changed files with 12 additions and 5 deletions
|
@ -27,9 +27,12 @@ export default abstract class RolePermissionCommandHandler {
|
|||
.transaction(async (manager) => {
|
||||
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions);
|
||||
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions);
|
||||
|
||||
await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions);
|
||||
await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions);
|
||||
if (newPermissions.length != 0) {
|
||||
await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions);
|
||||
}
|
||||
if (removePermissions.length != 0) {
|
||||
await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions);
|
||||
}
|
||||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
|
|
|
@ -27,8 +27,12 @@ export default abstract class UserPermissionCommandHandler {
|
|||
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions);
|
||||
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions);
|
||||
|
||||
await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions);
|
||||
await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions);
|
||||
if (newPermissions.length != 0) {
|
||||
await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions);
|
||||
}
|
||||
if (removePermissions.length != 0) {
|
||||
await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions);
|
||||
}
|
||||
})
|
||||
.then(() => {})
|
||||
.catch((err) => {
|
||||
|
|
Loading…
Reference in a new issue