Browse Source
Merge pull request #5869 from ViacheslavKlimov/fix/users-deletion
[3.3.3] Don't allow sysadmin to delete himself
pull/5879/head
Andrew Shvayka
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
0 deletions
-
application/src/main/java/org/thingsboard/server/controller/UserController.java
|
|
|
@ -302,6 +302,10 @@ public class UserController extends BaseController { |
|
|
|
UserId userId = new UserId(toUUID(strUserId)); |
|
|
|
User user = checkUserId(userId, Operation.DELETE); |
|
|
|
|
|
|
|
if (user.getAuthority() == Authority.SYS_ADMIN && getCurrentUser().getId().equals(userId)) { |
|
|
|
throw new ThingsboardException("Sysadmin is not allowed to delete himself", ThingsboardErrorCode.PERMISSION_DENIED); |
|
|
|
} |
|
|
|
|
|
|
|
List<EdgeId> relatedEdgeIds = findRelatedEdgeIds(getTenantId(), userId); |
|
|
|
|
|
|
|
userService.deleteUser(getCurrentUser().getTenantId(), userId); |
|
|
|
|