Ejemplo n.º 1
0
  @RequestMapping(value = "/me", method = RequestMethod.GET, produces = "application/json")
  public SystemUserResultBean get(
      @RequestHeader(value = "api-key", required = false) String apiHeaderKey)
      throws FlockException {
    // curl -u batch:123 -X GET http://localhost:8080/ab/profiles/me/

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    SystemUserResultBean su =
        new SystemUserResultBean(
            regService.getSystemUser(apiHeaderKey), userProfileService.getUser(auth));
    return su;
  }
Ejemplo n.º 2
0
  @RequestMapping(
      value = "/",
      consumes = "application/json",
      produces = "application/json",
      method = RequestMethod.POST)
  @ResponseStatus(value = HttpStatus.CREATED)
  public SystemUserResultBean registerSystemUser(@RequestBody RegistrationBean regBean)
      throws FlockException {
    // curl -u admin:hackme -H "Content-Type:application/json" -X PUT
    // http://localhost:8080/api/v1/profiles -d '{"name":"mikey", "companyName":"Monowai
    // Dev","password":"******"}'
    SystemUser su = regService.registerSystemUser(regBean);

    if (su == null) return new SystemUserResultBean(su);

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    return new SystemUserResultBean(su, userProfileService.getUser(auth));
  }