All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.smallcrew.security.web.ChangePasswordController Maven / Gradle / Ivy

Go to download

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy