source: src/main/java/it/finki/charitable/util/AutomaticEvents.java@ 3fc9e50

Last change on this file since 3fc9e50 was 3fc9e50, checked in by KostaFortumanov <kfortumanov@…>, 3 years ago

prototip part1

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package it.finki.charitable.util;
2
3import it.finki.charitable.entities.AppUser;
4import it.finki.charitable.security.ConfirmationToken;
5import it.finki.charitable.services.ConfirmationTokenService;
6import it.finki.charitable.services.UserService;
7import org.springframework.scheduling.annotation.Scheduled;
8import org.springframework.stereotype.Component;
9
10import java.util.List;
11
12@Component
13public class AutomaticEvents {
14
15 private final UserService userService;
16 private final ConfirmationTokenService confirmationTokenService;
17
18 public AutomaticEvents(UserService userService, ConfirmationTokenService confirmationTokenService) {
19 this.userService = userService;
20 this.confirmationTokenService = confirmationTokenService;
21 }
22
23 @Scheduled(cron = "0 0 0 * * *")
24 public void deleteNonEnabledUsers() {
25 List<ConfirmationToken> toDelete = confirmationTokenService.getAll();
26 for(ConfirmationToken token : toDelete) {
27 AppUser user = token.getUser();
28 confirmationTokenService.deleteConfirmationToken(token);
29 if(!user.getEnabled()) {
30 userService.deleteUser(user);
31 }
32 }
33 }
34}
Note: See TracBrowser for help on using the repository browser.