/**
* Creates an instance of this filter class
*
- * @return $filterInstance An instance of this filter class
+ * @param $controllerInstance An instance of a Controller class
+ * @return $filterInstance An instance of this filter class
*/
- public final static function createAccountPasswordVerifierFilter () {
+ public final static function createAccountPasswordVerifierFilter (Controller $controllerInstance) {
// Get a new instance
$filterInstance = new AccountPasswordVerifierFilter();
+ // Set the controller
+ $filterInstance->setControllerInstance($controllerInstance);
+
// Return the instance
return $filterInstance;
}
* @param $responseInstance An instance of a class with an Responseable interface
* @return void
* @throws AccountPasswordMismatchException If the account password does not match
+ * @todo Rewrite handling of different password fields
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get password
// Is the password still not set?
if (is_null($password)) {
- // Not found in form so stop the filtering process
- $requestInstance->requestIsValid(false);
+ // Get password from alternative location
+ $password = $requestInstance->getRequestElement('password');
- // Add a message to the response
- $responseInstance->addFatalMessage('pass_old_unset');
+ // Is the password still not set?
+ if (is_null($password)) {
+ // Not found in form so stop the filtering process
+ $requestInstance->requestIsValid(false);
- // Abort here
- return false;
- } elseif (empty($password)) {
+ // Add a message to the response
+ $responseInstance->addFatalMessage('password_unset');
+
+ // Abort here
+ return false;
+ } // END - if
+ } // END - if
+
+ if (empty($password)) {
// Password is empty
$requestInstance->requestIsValid(false);
// Add a message to the response
- $responseInstance->addFatalMessage('pass_old_empty');
+ $responseInstance->addFatalMessage('password_empty');
// Abort here
return false;
// Get a user instance
$userInstance = Registry::getRegistry()->getInstance('user');
- // Get old hash
- $oldHash = $userInstance->getField('pass_hash');
+ // Get current hash
+ $currentHash = $userInstance->getField('pass_hash');
// Get an encryption helper and encrypt the password
- $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $oldHash);
+ $passHash = ObjectFactory::createObjectByConfiguredName('crypto_class')->hashString($password, $currentHash);
// Does it match?
- if ($oldHash != $passHash) {
+ if ($currentHash != $passHash) {
// Throw an exception here to stop the proccessing
throw new AccountPasswordMismatchException($this, BaseUser::EXCEPTION_USER_PASS_MISMATCH);
} // END - if