@Secured(value = {"ROLE_ADMIN", "ROLE_MANAGER"})
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody void createUser(@RequestBody UserDto dto, Principal principal) {
    PipUser user = new PipUser();
    user.setEmail(dto.getEmail());
    Set<OrganisazionDto> organizations = dto.getOrganizations();
    if (organizations.isEmpty()) {
      PipUser currentUser =
          PipUser.findPipUsersByEmailEquals(principal.getName()).getSingleResult();
      List<Organisazion> organisazions = currentUser.getOrganisazions();
      if (!organisazions.isEmpty()) {
        user.getOrganisazions().add(organisazions.get(0));
      }
    } else {
      Organisazion organisazion =
          Organisazion.findOrganisazionsByName(
                  new ArrayList<OrganisazionDto>(organizations).get(0).getName())
              .getSingleResult();
      user.getOrganisazions().add(organisazion);
    }

    String randomPassword = RandomStringUtils.randomAlphanumeric(6);
    user.setPassword(encoder.encode(randomPassword));
    user.setRole(PipRole.USER.getName());
    user.persist();
    mailingUtil.sendCreationMail(user, randomPassword);
  }
 @RequestMapping(method = RequestMethod.GET, value = "request-new-pw")
 public String requestPassword(@RequestParam("email") String email, ModelMap model) {
   List<PipUser> resultList = PipUser.findPipUsersByEmailEquals(email).getResultList();
   boolean userExists = !resultList.isEmpty();
   if (!userExists) model.addAttribute("error", "User already exists");
   else {
     PipUser user = resultList.get(0);
     String randomPassword = RandomStringUtils.randomAlphanumeric(6);
     user.setPassword(encoder.encode(randomPassword));
     user.merge();
     mailingUtil.sendCreationMail(user, randomPassword);
   }
   return "redirect:/";
 }