Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation and Custom-Validator throws error since flow 6 #50

Merged
merged 5 commits into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Classes/Controller/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Flow\Security\Account;
use Neos\Flow\Security\AccountRepository;
use Neos\Flow\Security\Authentication\AuthenticationManagerInterface;
use Neos\Flow\Security\Authentication\TokenAndProviderFactoryInterface;
use Neos\Flow\Security\Authentication\Token\UsernamePassword;
use Neos\Flow\Security\Authentication\TokenInterface;
use Neos\Flow\Security\Context;
Expand All @@ -31,11 +31,11 @@ class ProfileController extends ActionController
*/
protected $userRepository;

/**
* @Flow\Inject
* @var AuthenticationManagerInterface
*/
protected $authenticationManager;
/**
* @Flow\Inject
* @var TokenAndProviderFactoryInterface
*/
protected $tokenAndProviderFactory;

/**
* @Flow\Inject
Expand Down Expand Up @@ -104,7 +104,7 @@ protected function getErrorFlashMessage()
*/
protected function setPassword(Account $account, $password)
{
$tokens = $this->authenticationManager->getTokens();
$tokens = $this->tokenAndProviderFactory->getTokens();
$indexedTokens = array();
foreach ($tokens as $token) {
/** @var TokenInterface $token */
Expand Down
18 changes: 10 additions & 8 deletions Classes/Domain/Validator/RegistrationFlowValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,31 @@ class RegistrationFlowValidator extends AbstractValidator
*/
protected function isValid($value)
{

/** @noinspection PhpUndefinedMethodInspection */
$existingAccount = $this->accountRepository->findOneByAccountIdentifier($value->getEmail());

if ($existingAccount) {
$message = $this->translator->translateById('validations.registrationflow.email', [$value->getEmail()], null, null, 'Main', 'Sandstorm.UserManagement');
$this->result->forProperty('email')->addError(new Error($message, 1336499566));
$this->getResult()->forProperty('email')->addError(new Error($message, 1336499566));
}

// If a custom validation service is registered, call its validate method to allow custom validations during registration
if ($this->objectManager->isRegistered(RegistrationFlowValidationServiceInterface::class)) {
$instance = $this->objectManager->get(RegistrationFlowValidationServiceInterface::class);
$instance->validateRegistrationFlow($value, $this);
}

}

/**
* The custom validation service might need to access the result directly, so it is exposed here
*
* @return Result
*/
public function getResult()
{
return $this->result;
}
skurfuerst marked this conversation as resolved.
Show resolved Hide resolved
*/
public function getResult()
{
return parent::getResult();
}

}