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

fr.smallcrew.security.web.SubscribeController 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.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());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy