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) => {
|
.transaction(async (manager) => {
|
||||||
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions);
|
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions);
|
||||||
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions);
|
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions);
|
||||||
|
if (newPermissions.length != 0) {
|
||||||
await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions);
|
await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions);
|
||||||
await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions);
|
}
|
||||||
|
if (removePermissions.length != 0) {
|
||||||
|
await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
|
@ -27,8 +27,12 @@ export default abstract class UserPermissionCommandHandler {
|
||||||
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions);
|
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions);
|
||||||
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions);
|
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions);
|
||||||
|
|
||||||
await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions);
|
if (newPermissions.length != 0) {
|
||||||
await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions);
|
await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions);
|
||||||
|
}
|
||||||
|
if (removePermissions.length != 0) {
|
||||||
|
await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(() => {})
|
.then(() => {})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|
Loading…
Reference in a new issue