Пример #1
0
 /**
  * @View(serializerGroups={"api"})
  * @ApiDoc(
  *     description="Creates a user",
  *     views = {"user"},
  *     input="Claroline\CoreBundle\Form\ProfileCreationType"
  * )
  */
 public function postUserAction()
 {
     $roleUser = $this->roleManager->getRoleByName('ROLE_USER');
     $profileType = new ProfileCreationType($this->localeManager, array($roleUser), true, $this->authenticationManager->getDrivers());
     $profileType->enableApi();
     $form = $this->formFactory->create($profileType);
     $form->submit($this->request);
     //$form->handleRequest($this->request);
     if ($form->isValid()) {
         $roles = $form->get('platformRoles')->getData();
         $user = $form->getData();
         $user = $this->userManager->createUser($user, false, $roles);
         //maybe only do this if a parameter is present in platform_options.yml
         $this->mailManager->sendInitPassword($user);
         return $user;
     }
     return $form;
 }
Пример #2
0
 /**
  * @View(serializerGroups={"api_user"})
  * @ApiDoc(
  *     description="Creates a user",
  *     views = {"user"},
  *     input="Claroline\CoreBundle\Form\ProfileCreationType"
  * )
  */
 public function postUserAction()
 {
     $this->throwExceptionIfNotGranted('create', new User());
     $roleUser = $this->roleManager->getRoleByName('ROLE_USER');
     $profileType = new ProfileCreationType($this->localeManager, [$roleUser], true, $this->authenticationManager->getDrivers());
     $profileType->enableApi();
     $form = $this->formFactory->create($profileType);
     $form->submit($this->request);
     if ($form->isValid()) {
         //can we create the user in the current organization ?
         $roles = $form->get('platformRoles')->getData();
         $user = $form->getData();
         $user = $this->userManager->createUser($user, false, $roles);
         //maybe only do this if a parameter is present in platform_options.yml
         $this->mailManager->sendInitPassword($user);
         return $user;
     }
     return $form;
 }