fr.smallcrew.security.web.ChangePasswordController Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smallcrew-security Show documentation
Show all versions of smallcrew-security Show documentation
Foundation of all smallcrew's projects needing authenticated users and role management
The newest version!
package fr.smallcrew.security.web;
import fr.smallcrew.security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Controller
@RequestMapping("/changePassword")
public class ChangePasswordController {
@Autowired
private UserService userService;
@Autowired
private LoginController loginController;
@RequestMapping(method = RequestMethod.POST)
public AuthenticatedUserPublic lostPassword(HttpServletRequest request, HttpServletResponse response,
@RequestParam("email") String email,
@RequestParam("token") String token,
@RequestParam("newPassword") String newPassword,
@RequestParam("newPasswordConfirmed") String newPasswordConfirmed) {
userService.changePassword(email, token, newPassword, newPasswordConfirmed);
return loginController.doLogin(request, response, email, newPassword);
}
}