Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] springboot-registration-login project's auto login method #2

Open
pereira-a opened this issue Apr 7, 2019 · 0 comments
Open

Comments

@pereira-a
Copy link

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";
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant