Refactor RegistrationController

This commit is contained in:
pivovarit 2017-01-18 08:13:39 +01:00
parent 056bbc02af
commit ada5fca2d5
1 changed files with 6 additions and 7 deletions

View File

@ -1,11 +1,9 @@
package org.baeldung.config; package org.baeldung.config;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;
import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.BadCredentialsException;
@ -14,9 +12,10 @@ import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.WebAuthenticationDetails; import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.context.annotation.Profile; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* Manually authenticate a user using Spring Security / Spring Web MVC' (upon successful account registration) * Manually authenticate a user using Spring Security / Spring Web MVC' (upon successful account registration)
@ -40,7 +39,7 @@ public class RegistrationController {
* @return The view. Page confirming either successful registration (and/or * @return The view. Page confirming either successful registration (and/or
* successful authentication) or failed registration. * successful authentication) or failed registration.
*/ */
@RequestMapping(value = "/register", method = RequestMethod.GET) @GetMapping("/register")
public String registerAndAuthenticate(HttpServletRequest request, HttpServletResponse response) { public String registerAndAuthenticate(HttpServletRequest request, HttpServletResponse response) {
logger.debug("registerAndAuthenticate: attempt to register, application should manually authenticate."); logger.debug("registerAndAuthenticate: attempt to register, application should manually authenticate.");