Skip to content

Commit

Permalink
update: Hard delete user/usergroup when not used
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Oct 31, 2024
1 parent 1d8090f commit e4b4a7b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/org/isf/menu/service/MenuIoOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public long countAllActiveGroups() {
* @throws OHServiceException When error occurs
*/
public List<User> getUser(String groupID) throws OHServiceException {
return repository.findByDeletedWhereUserGroupNameByOrderUserNameAsc(groupID, false);
return repository.findAllWhereUserGroupNameByOrderUserNameAsc(groupID);
}

/**
Expand Down Expand Up @@ -204,8 +204,12 @@ public boolean updatePassword(User user) throws OHServiceException {
*/
public void deleteUser(User user) throws OHServiceException {
ensureUserNotDeleted(user.getUserName());
user.setDeleted(true);
repository.save(user);
try {
repository.delete(user);
} catch (Exception ex) {
user.setDeleted(true);
repository.save(user);
}
}

public void updateFailedAttempts(String userName, int newFailAttempts) {
Expand Down Expand Up @@ -307,8 +311,12 @@ private GroupMenu insertGroupMenu(UserGroup aGroup, UserMenuItem item) throws OH
*/
public void deleteGroup(UserGroup aGroup) throws OHServiceException {
ensureUserGroupNotDeleted(aGroup.getCode());
aGroup.setDeleted(true);
groupRepository.save(aGroup);
if (getUser(aGroup.getCode()).isEmpty()) {
groupRepository.delete(aGroup);
} else {
aGroup.setDeleted(true);
groupRepository.save(aGroup);
}
}

/**
Expand Down

0 comments on commit e4b4a7b

Please sign in to comment.