for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of the Extension "fe_change_pwd" for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/
namespace Derhansen\FeChangePwd\Service;
use Derhansen\FeChangePwd\Exception\MissingPasswordHashServiceException;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Class OldPasswordsService
class OldPasswordService
{
* Returns if the given $passwordToCheck is equals the old password by using the given current password hash
* @param string $passwordToCheck
* @param string $oldPasswordHash
* @return bool
* @throws MissingPasswordHashServiceException
public function checkEqualsOldPassword(string $passwordToCheck, string $oldPasswordHash): bool
if (class_exists(PasswordHashFactory::class)) {
$hashInstance = GeneralUtility::makeInstance(PasswordHashFactory::class)->getDefaultHashInstance('FE');
$equals = $hashInstance->checkPassword(
$passwordToCheck,
$oldPasswordHash
);
} else {
throw new MissingPasswordHashServiceException(
'No secure password hashing service could be initialized. Please check your TYPO3 system configuration',
1557550040
}
return $equals;