2
2
3
3
import lombok .extern .apachecommons .CommonsLog ;
4
4
import org .springframework .beans .factory .annotation .Autowired ;
5
- import org .springframework .context .ApplicationEventPublisher ;
6
5
import org .springframework .http .HttpStatus ;
7
6
import org .springframework .security .authentication .AnonymousAuthenticationToken ;
8
7
import org .springframework .security .core .Authentication ;
16
15
import org .springframework .web .bind .annotation .RequestParam ;
17
16
import org .springframework .web .servlet .ModelAndView ;
18
17
import org .springframework .web .servlet .mvc .support .RedirectAttributes ;
19
- import ubc .pavlab .rdp .events .OnRegistrationCompleteEvent ;
20
18
import ubc .pavlab .rdp .exception .TokenException ;
21
19
import ubc .pavlab .rdp .model .Profile ;
22
20
import ubc .pavlab .rdp .model .User ;
23
- import ubc .pavlab .rdp .model .VerificationToken ;
24
21
import ubc .pavlab .rdp .services .PrivacyService ;
25
22
import ubc .pavlab .rdp .services .UserService ;
26
23
import ubc .pavlab .rdp .settings .ApplicationSettings ;
@@ -43,9 +40,6 @@ public class LoginController {
43
40
@ Autowired
44
41
private ApplicationSettings applicationSettings ;
45
42
46
- @ Autowired
47
- private ApplicationEventPublisher eventPublisher ;
48
-
49
43
@ GetMapping ("/login" )
50
44
public ModelAndView login () {
51
45
ModelAndView modelAndView = new ModelAndView ( "login" );
@@ -67,7 +61,6 @@ public ModelAndView registration() {
67
61
return modelAndView ;
68
62
}
69
63
70
- @ Transactional
71
64
@ PostMapping ("/registration" )
72
65
public ModelAndView createNewUser ( @ Validated (User .ValidationUserAccount .class ) User user ,
73
66
BindingResult bindingResult ,
@@ -94,8 +87,7 @@ public ModelAndView createNewUser( @Validated(User.ValidationUserAccount.class)
94
87
modelAndView .setStatus ( HttpStatus .BAD_REQUEST );
95
88
} else {
96
89
user = userService .create ( user );
97
- VerificationToken token = userService .createVerificationTokenForUser ( user );
98
- eventPublisher .publishEvent ( new OnRegistrationCompleteEvent ( user , token , locale ) );
90
+ userService .createVerificationTokenForUser ( user , locale );
99
91
redirectAttributes .addFlashAttribute ( "message" , "Your user account was registered successfully. Please check your email for completing the completing the registration process." );
100
92
modelAndView .setViewName ( "redirect:/login" );
101
93
}
@@ -108,7 +100,6 @@ public ModelAndView resendConfirmation() {
108
100
return new ModelAndView ( "resendConfirmation" );
109
101
}
110
102
111
- @ Transactional
112
103
@ PostMapping (value = "/resendConfirmation" )
113
104
public ModelAndView resendConfirmation ( @ RequestParam ("email" ) String email , Locale locale ) {
114
105
ModelAndView modelAndView = new ModelAndView ( "resendConfirmation" );
@@ -125,8 +116,7 @@ public ModelAndView resendConfirmation( @RequestParam("email") String email, Loc
125
116
modelAndView .addObject ( "message" , "User is already enabled." );
126
117
return modelAndView ;
127
118
} else {
128
- VerificationToken token = userService .createVerificationTokenForUser ( user );
129
- eventPublisher .publishEvent ( new OnRegistrationCompleteEvent ( user , token , locale ) );
119
+ userService .createVerificationTokenForUser ( user , locale );
130
120
modelAndView .addObject ( "message" , "Confirmation email sent." );
131
121
}
132
122
0 commit comments