[BUG] springboot-registration-login project's auto login method
pereira-a opened this issue · comments
In order to create the authentication token at the SecurityServiceImpl class, it's needed to pass to the constructor the password in plain text.
I recommend saving the password in registration mapping and then pass it to autologin.
Example:
@PostMapping("/registration")
public String registration(@ModelAttribute("userForm") User userForm, BindingResult bindingResult) {
String pw = userForm.getPassword();
userValidator.validate(userForm, bindingResult);
if (bindingResult.hasErrors()) {
return "registration";
}
userService.save(userForm);
securityService.autoLogin(userForm.getUsername(), pw);
return "redirect:/welcome";
}