Skip to content
Snippets Groups Projects
Commit a7495dae authored by Marc Egger's avatar Marc Egger
Browse files

Password.php: make Password functions static, run Typo3 bootstrap

parent 4cc6bd5c
No related branches found
No related tags found
1 merge request!122F7165 fe user registration
Pipeline #1497 passed
......@@ -25,10 +25,10 @@ class Password {
* @param string $newPassword
* @return string
*/
public function getHash($newPassword) {
public static function getHash($newPassword) {
$saltedPassword = md5($newPassword); // Use md5 as fallback
$this->t3AutoloadIfNotRunning();
self::t3AutoloadIfNotRunning();
if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
$objSalt = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance(NULL);
if (is_object($objSalt)) {
......@@ -46,9 +46,9 @@ class Password {
* @param string $password
* @return bool
*/
public function checkPassword($saltedPassword, $password) {
public static function checkPassword($saltedPassword, $password) {
$this->t3AutoloadIfNotRunning();
self::t3AutoloadIfNotRunning();
$success = FALSE;
if (\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility::isUsageEnabled('FE')) {
$objSalt2 = \TYPO3\CMS\Saltedpasswords\Salt\SaltFactory::getSaltingInstance($saltedPassword);
......@@ -62,11 +62,21 @@ class Password {
/**
* Load Typo3 autoloader if Typo3 is not instantiated
*/
public function t3AutoloadIfNotRunning() {
public static function t3AutoloadIfNotRunning() {
if (!isset($GLOBALS['TSFE'])) {
if (!class_exists('\TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility')) {
//TODO: Get absolute 'path' via QFQ config
require __DIR__ . '/../../../../../../typo3_src/vendor/autoload.php';
// run typo3 bootstrap if not yet happened. Necessary if run in unittest.
if (!defined('TYPO3_MODE')) {
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()
->setRequestType(TYPO3_REQUESTTYPE_AJAX)
->baseSetup(0);
// Alternate error fix if you don't want to run Typo3 bootstrap:
// error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
define('TYPO3_MODE', 'FE');
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment