Skip to content

Commit

Permalink
Do not delete expired user-roles without notification
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed May 15, 2024
1 parent 485062c commit 853cd69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/src/main/java/access/cron/ResourceCleaner.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private List<User> cleanOrphanedUser() {
}

private List<UserRole> cleanUserRoles() {
List<UserRole> userRoles = userRoleRepository.findByEndDateBefore(Instant.now());
List<UserRole> userRoles = userRoleRepository.findByEndDateBeforeAndExpiryNotifications(Instant.now(), 1);

LOG.info(String.format("Deleted %s userRoles with an endDate in the past: %s",
userRoles.size(),
Expand Down
5 changes: 4 additions & 1 deletion server/src/test/java/access/cron/ResourceCleanerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ private void deleteUserRoles(String sub) {
private void markUserRole(String sub) {
User user = userRepository.findBySubIgnoreCase(sub).get();
Instant past = Instant.now().minus(Period.ofDays(1050));
user.getUserRoles().forEach(userRole -> userRole.setEndDate(past));
user.getUserRoles().forEach(userRole -> {
userRole.setEndDate(past);
userRole.setExpiryNotifications(1);
});
userRepository.save(user);
}

Expand Down

0 comments on commit 853cd69

Please sign in to comment.