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); }
public function indexAction() { $userId = $this->params()->fromRoute('userId', null); try { $this->service->proceed($userId); $this->notification()->info('User email verified successfully. You need to set a password to log in.'); return $this->redirect()->toRoute('lang/my', array('action' => 'password')); } catch (Exception\UserNotFoundException $e) { $this->notification()->danger('User cannot be found'); } catch (\Exception $e) { $this->logger->crit($e); $this->notification()->danger('An unexpected error has occurred, please contact your system administrator'); } return $this->redirect()->toRoute('lang/register'); }
public function indexAction() { $userId = $this->params()->fromRoute('userId', null); $token = $this->params()->fromRoute('token', null); try { $this->service->proceed($userId, $token); return $this->redirect()->toRoute('lang/my', array('action' => 'password')); } catch (Exception\TokenExpirationDateExpiredException $e) { $this->notification()->danger('Cannot proceed, token expired'); } catch (Exception\UserNotFoundException $e) { $this->notification()->danger('User cannot be found for specified token'); } catch (\Exception $e) { $this->logger->crit($e); $this->notification()->danger('An unexpected error has occurred, please contact your system administrator'); } return $this->redirect()->toRoute('lang/forgot-password'); }
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; }
/** * @param Event $e * @return void */ public function onNotify(Event $e) { /* @var $user \User\Entity\UserInterface */ $user = $e->getParam('user'); $notifications = $e->getParam('notifications'); if (!$notifications instanceof Collection) { $notifications = new ArrayCollection($notifications); } $subject = new ViewModel(); $body = new ViewModel(['user' => $user, 'notifications' => $notifications]); $subject->setTemplate('mailman/messages/notification/subject'); $body->setTemplate('mailman/messages/notification/body'); try { $subjectHtml = $this->getRenderer()->render($subject); $bodyHtml = $this->getRenderer()->render($body); $this->getMailman()->send($user->getEmail(), $this->getMailman()->getDefaultSender(), $subjectHtml, $bodyHtml); } catch (\Exception $e) { // TODO: Persist email and try resending it later $log = $this->exceptionToString($e); $this->logger->crit($log); var_dump($e->getMessage(), $e->getTraceAsString()); } }
/** * Login with HybridAuth * * Passed in Params: * - provider: HybridAuth provider identifier. * * Redirects To: Route 'home' */ public function loginAction() { $ref = urldecode($this->getRequest()->getBasePath() . $this->params()->fromQuery('ref')); $provider = $this->params('provider', '--keiner--'); $hauth = $this->serviceLocator->get('HybridAuthAdapter'); $hauth->setProvider($provider); $auth = $this->auth; $result = $auth->authenticate($hauth); $resultMessage = $result->getMessages(); if (array_key_exists('firstLogin', $resultMessage) && $resultMessage['firstLogin'] === true) { try { $user = $auth->getUser(); $password = substr(md5(uniqid()), 0, 6); $login = uniqid() . ($this->options->auth_suffix != "" ? '@' . $this->options->auth_suffix : ''); $externalLogin = isset($user->login) ? $user->login : '******'; $this->logger->debug('first login via ' . $provider . ' as: ' . $externalLogin); $user->login = $login; $user->setPassword($password); $user->setRole($this->options->getRole()); $mail = $this->mailer('htmltemplate'); $mail->setTemplate('mail/first-socialmedia-login'); $mail->setSubject($this->options->getMailSubjectRegistration()); $mail->setVariables(array('displayName' => $user->getInfo()->getDisplayName(), 'provider' => $provider, 'login' => $login, 'password' => $password)); $mail->addTo($user->getInfo()->getEmail()); $loggerId = $login . ' (' . $provider . ': ' . $externalLogin . ')'; if (isset($mail) && $this->mailer($mail)) { $this->logger->info('Mail first-login for ' . $loggerId . ' sent to ' . $user->getInfo()->getEmail()); } else { $this->logger->warn('No Mail was sent for ' . $loggerId); } } catch (\Exception $e) { $this->logger->crit($e); $this->notification()->danger('An unexpected error has occurred, please contact your system administrator'); } } $user = $auth->getUser(); $this->logger->info('User ' . $auth->getUser()->getInfo()->getDisplayName() . ' logged in via ' . $provider); $settings = $user->getSettings('Core'); if (null !== $settings->localization->language) { $basePath = $this->getRequest()->getBasePath(); $ref = preg_replace('~^' . $basePath . '/[a-z]{2}(?=/|$)~', $basePath . '/' . $settings->localization->language, $ref); } return $this->redirect()->toUrl($ref); }
public function execute(MvcEvent $e) { if ($exception = $e->getParam('exception')) { $this->logger->crit($exception); } }