/** * @param RegistrationFlow $registrationFlow */ public function registerAction(RegistrationFlow $registrationFlow) { // We remove already existing flows $alreadyExistingFlows = $this->registrationFlowRepository->findByEmail($registrationFlow->getEmail()); if (count($alreadyExistingFlows) > 0) { foreach ($alreadyExistingFlows as $alreadyExistingFlow) { $this->registrationFlowRepository->remove($alreadyExistingFlow); } } $registrationFlow->storeEncryptedPassword(); // Send out a confirmation mail $activationLink = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('activateAccount', ['token' => $registrationFlow->getActivationToken()], 'Registration'); $this->emailService->sendTemplateBasedEmail('ActivationToken', $this->subjectActivation, [$this->emailSenderAddress => $this->emailSenderName], [$registrationFlow->getEmail()], ['activationLink' => $activationLink, 'applicationName' => $this->emailSenderName, 'registrationFlow' => $registrationFlow, 'baseUri' => htmlspecialchars($this->controllerContext->getRequest()->getHttpRequest()->getBaseUri())]); $this->registrationFlowRepository->add($registrationFlow); $this->view->assign('email', $registrationFlow->getEmail()); }
/** * @param ResetPasswordFlow $resetPasswordFlow */ public function requestTokenAction(ResetPasswordFlow $resetPasswordFlow) { $account = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($resetPasswordFlow->getEmail(), 'Sandstorm.UserManagement:Login'); if ($account !== null) { $alreadyExistingFlows = $this->resetPasswordFlowRepository->findByEmail($resetPasswordFlow->getEmail()); if (count($alreadyExistingFlows) > 0) { foreach ($alreadyExistingFlows as $alreadyExistingFlow) { $this->resetPasswordFlowRepository->remove($alreadyExistingFlow); } } // Send out a confirmation mail $resetPasswordLink = $this->uriBuilder->reset()->setCreateAbsoluteUri(true)->uriFor('insertNewPassword', ['token' => $resetPasswordFlow->getResetPasswordToken()], 'ResetPassword'); $this->emailService->sendTemplateBasedEmail('ResetPasswordToken', $this->subjectResetPassword, [$this->emailSenderAddress => $this->emailSenderName], [$resetPasswordFlow->getEmail()], ['resetPasswordLink' => $resetPasswordLink, 'applicationName' => $this->emailSenderName, 'resetPasswordFlow' => $resetPasswordFlow, 'baseUri' => htmlspecialchars($this->controllerContext->getRequest()->getHttpRequest()->getBaseUri())]); $this->resetPasswordFlowRepository->add($resetPasswordFlow); } $this->view->assign('resetPasswordFlow', $resetPasswordFlow); $this->view->assign('account', $account); }