Ejemplo n.º 1
0
 public function indexAction()
 {
     /** @var \Zend\Http\Request $request */
     $request = $this->getRequest();
     try {
         if ($request->isPost()) {
             $this->form->setData($request->getPost()->toArray() ?: array());
             if ($this->form->isValid()) {
                 $mailer = $this->getPluginManager()->get('Mailer');
                 $url = $this->plugin('url');
                 // we cannot check reCaptcha twice (security protection) so we have to remove it
                 $filter = $this->form->getInputFilter()->remove('captcha');
                 $this->service->proceed($filter, $mailer, $url);
                 $this->notification()->success('An Email with an activation link has been sent, please try to check your email box');
             } else {
                 $this->notification()->danger('Please fill form correctly');
             }
         }
     } catch (Exception\UserAlreadyExistsException $e) {
         $this->notification()->danger('User with this email address already exists');
     } catch (\Exception $e) {
         $this->logger->crit($e);
         $this->notification()->danger('An unexpected error has occurred, please contact your system administrator');
     }
     $this->form->setAttribute('action', $this->url()->fromRoute('lang/register'));
     return array('form' => $this->form);
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     if (!$this->options->getEnableRegistration()) {
         $this->notification()->info('Registration is disabled');
         return $this->redirect()->toRoute('lang');
     }
     /** @var \Zend\Http\Request $request */
     $request = $this->getRequest();
     $viewModel = new ViewModel();
     try {
         if ($request->isPost()) {
             $this->form->setData($request->getPost()->toArray() ?: array());
             if ($this->form->isValid()) {
                 $mailer = $this->getPluginManager()->get('Mailer');
                 $url = $this->plugin('url');
                 // we cannot check reCaptcha twice (security protection) so we have to remove it
                 $filter = $this->form->getInputFilter()->remove('captcha');
                 $this->service->proceed($filter, $mailer, $url);
                 $this->notification()->success('An Email with an activation link has been sent, please try to check your email box');
                 $viewModel->setTemplate('auth/register/completed');
             } else {
                 $viewModel->setTemplate(null);
                 $this->notification()->danger('Please fill form correctly');
             }
         } else {
             /* @var $register \Zend\Form\Fieldset */
             $register = $this->form->get('register');
             $register->get('role')->setValue($this->params('role'));
         }
     } catch (Exception\UserAlreadyExistsException $e) {
         $this->notification()->danger('User with this email address already exists');
     } catch (\Auth\Exception\UserDeactivatedException $e) {
         $this->notification()->danger('User with this email address already exists');
     } catch (\Exception $e) {
         $this->logger->crit($e);
         $this->notification()->danger('An unexpected error has occurred, please contact your system administrator');
     }
     $this->form->setAttribute('action', $this->url()->fromRoute('lang/register'));
     $viewModel->setVariable('form', $this->form);
     return $viewModel;
 }