-
Notifications
You must be signed in to change notification settings - Fork 1
Code Review: User grouping RBAC #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: unified/with-code-review
Are you sure you want to change the base?
Code Review: User grouping RBAC #44
Conversation
| UserGroup group = findGroupById(roleAssignmentDto.getGroupId()); | ||
|
|
||
| // BUG 1: No validation for empty role collections - unnecessary processing | ||
| for (Long roleId : roleAssignmentDto.getRoleIds()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No validation for empty role collections - unnecessary processing
| .filter(group -> !group.isDeleted()) | ||
| .forEach(group -> { | ||
| // Extra unnecessary database call for each group | ||
| UserGroup refreshedGroup = userGroupRepository.findById(group.getId()).orElse(group); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance issue - unnecessary database calls in loop
|
|
||
| public boolean hasPermission(Long userId, String permission) { | ||
| // BUG 2: Incorrect logic - should check if user has permission, not if they don't | ||
| return !getAllPermissionsForUser(userId).contains(permission); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect logic - should check if user has permission, not if they don't
| .deleted(group.isDeleted()) | ||
| .deletedAt(group.getDeletedAt()) | ||
| // BUG 3: Data integrity issue - including deleted members/roles in counts | ||
| .memberIds(group.getMembers().stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data integrity issue - including deleted members/roles in counts
|
|
||
| public void addMember(Account account) { | ||
| // BUG 4: Missing null check - will cause NullPointerException | ||
| this.members.add(account); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing null check - will cause NullPointerException
| public void removeMember(Account account) { | ||
| // BUG 7: Memory leak - only removing from one side of bidirectional relationship | ||
| this.members.remove(account); | ||
| // account.getUserGroups().remove(this); // Commented out - causes memory leak |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory leak - only removing from one side of bidirectional relationship
| UserGroup existingGroup = findGroupById(groupId); | ||
|
|
||
| // BUG 6: Case sensitivity bug - allows duplicate names with different cases | ||
| if (!existingGroup.getName().equals(groupDto.getName()) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Case sensitivity bug - allows duplicate names with different cases
Code Review: User grouping RBAC