Last change
on this file since 2d8c0e7 was 3fc9e50, checked in by KostaFortumanov <kfortumanov@…>, 3 years ago |
prototip part1
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | package it.finki.charitable.util;
|
---|
2 |
|
---|
3 | import it.finki.charitable.entities.AppUser;
|
---|
4 | import it.finki.charitable.security.ConfirmationToken;
|
---|
5 | import it.finki.charitable.services.ConfirmationTokenService;
|
---|
6 | import it.finki.charitable.services.UserService;
|
---|
7 | import org.springframework.scheduling.annotation.Scheduled;
|
---|
8 | import org.springframework.stereotype.Component;
|
---|
9 |
|
---|
10 | import java.util.List;
|
---|
11 |
|
---|
12 | @Component
|
---|
13 | public 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.