fr.smallcrew.security.web.SubscribeController 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.domain.DomainUser;
import fr.smallcrew.security.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static org.springframework.web.bind.annotation.RequestMethod.POST;
@Controller
@RequestMapping("/subscribe")
public class SubscribeController {
@Autowired
private UserService userService;
@Autowired
private LoginController loginController;
@RequestMapping(method = POST)
public AuthenticatedUserPublic create(HttpServletRequest request, HttpServletResponse response, @RequestBody DomainUser user) {
userService.create(user);
return loginController.doLogin(request, response, user.getEmail(), user.getPassword());
}
}