Exemplo n.º 1
0
 /**
  * @param Token $token
  * @return void
  */
 public function createAction(Token $token = NULL)
 {
     if ($token === NULL) {
         $this->addFlashMessage('The activation link is not valid.', '', Message::SEVERITY_ERROR);
         $this->forward('createError');
     }
     $user = $token->getMeta()['user'];
     $result = $this->crowdClient->addUser($user->getFirstname(), $user->getLastname(), $user->getEmail(), $user->getUsername(), $user->getPassword());
     if (!$result->hasErrors()) {
         $this->addFlashMessage('Your account was created successfully. You can now sing in with your credentials.', 'Account created', Message::SEVERITY_OK);
         $this->redirect('index');
     } else {
         $error = $result->getFirstError();
         $this->addFlashMessage($error->getMessage(), $error->getTitle(), Message::SEVERITY_ERROR);
         $this->forward('createError');
     }
 }
Exemplo n.º 2
0
 /**
  * Sends an activation mail for $token to the given $recipientAddress.
  *
  * The mail is built and sent according to the configuration given in the preset assigned to the $token.
  *
  * @param string $recipientAddress
  * @param Token $token
  * @param array $additionalTemplateVariables
  * @return int
  */
 public function sendActivationMail($recipientAddress, Token $token, array $additionalTemplateVariables = [])
 {
     $preset = $token->getPreset();
     $activationLink = $this->getActivationLink($token);
     $mail = new Message();
     $mail->setFrom([$preset['mail']['from']['address'] => $preset['mail']['from']['name']])->setTo($recipientAddress)->setSubject($preset['mail']['subject']);
     $templateVariables = array_merge(['activationLink' => $activationLink, 'recipientAddress' => $recipientAddress, 'token' => $token, 'meta' => $token->getMeta()], $additionalTemplateVariables);
     $this->fluidView->setTemplatePathAndFilename($preset['mail']['message']['plaintext']);
     $this->fluidView->assignMultiple($templateVariables);
     $mail->setBody($this->fluidView->render(), 'text/plain');
     if (isset($preset['mail']['html'])) {
         $this->fluidView->setTemplatePathAndFilename($preset['mail']['message']['html']);
         $this->fluidView->assignMultiple($templateVariables);
         $mail->setBody($this->fluidView->render(), 'text/html');
     }
     return $mail->send();
 }
 /**
  * @param Token $token
  * @return void
  */
 public function onetimeLoginAction(Token $token)
 {
     $username = $token->getMeta()['name'];
     /** @var $account \TYPO3\Flow\Security\Account */
     $account = NULL;
     $providerName = $this->authenticationProviderName;
     $accountRepository = $this->accountRepository;
     $this->securityContext->withoutAuthorizationChecks(function () use($username, $providerName, $accountRepository, &$account) {
         $account = $accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($username, $providerName);
     });
     foreach ($this->securityContext->getAuthenticationTokens() as $authenticationToken) {
         if ($authenticationToken->getAuthenticationProviderName() === $providerName) {
             $authenticationToken->setAuthenticationStatus(TokenInterface::AUTHENTICATION_SUCCESSFUL);
             $authenticationToken->setAccount($account);
             break;
         }
     }
     $this->redirect('resetForm');
 }