Skip to content

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

@pereira-a

Description

@pereira-a

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";
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions