fr.smallcrew.security.web.LostPasswordController 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.rest.data.PrimitiveValue;
import fr.smallcrew.security.data.LostPasswordData;
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;
@Controller
@RequestMapping("/lostPassword")
public class LostPasswordController {
@Autowired
private UserService userService;
@RequestMapping(method = RequestMethod.POST)
public PrimitiveValue lostPassword(HttpServletRequest request, @RequestParam("username") String username) {
LostPasswordData data = userService.sendLostPasswordMail(username, request.getLocale());
return PrimitiveValue.from(data.getEmail());
}
}