Created
March 5, 2013 09:39
-
-
Save jp1987/5089105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\App\Validation\Validator; | |
use TYPO3\Flow\Annotations as Flow; | |
/** | |
* Checks if the specified password matches the current user's password | |
* | |
* @Flow\Scope("singleton") | |
*/ | |
class CurrentPasswordValidator extends \TYPO3\Flow\Validation\Validator\AbstractValidator { | |
/** | |
* @Flow\Inject | |
* @var \TYPO3\Flow\Security\Context | |
*/ | |
protected $securityContext; | |
/** | |
* @var \TYPO3\Flow\Security\Cryptography\HashService | |
* @Flow\Inject | |
*/ | |
protected $hashService; | |
/** | |
* @param mixed $value The value that should be validated | |
* @return void | |
*/ | |
protected function isValid($value) { | |
$account = $this->securityContext->getPartyByType('\My\App\Domain\Model\User\User'); | |
$accounts = $account->getAccounts(); | |
if (!($this->hashService->validatePassword($value, $accounts->first()->getCredentialsSource()))) { | |
$this->addError('Current password is not correct', 1345976880); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment