[CLEANUP] Remove code duplication in saltedpasswords
authorAndreas Wolf <andreas.wolf@ikt-werk.de>
Mon, 6 Jun 2011 21:12:45 +0000 (23:12 +0200)
committerSusanne Moog <typo3@susannemoog.de>
Mon, 22 Aug 2011 17:20:40 +0000 (19:20 +0200)
There is some duplicate code in tx_saltedpasswords_sv1::authUser().
This patch removes the code, making it more readable.

Change-Id: Ie461059bcc699936774a8e41475a9cbbc98d9606
Resolves: #29157
Releases: 4.5, 4.6
Reviewed-on: http://review.typo3.org/3039
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
typo3/sysext/saltedpasswords/sv1/class.tx_saltedpasswords_sv1.php

index 3879d58..6e16397 100644 (file)
@@ -219,9 +219,6 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                $validPasswd = FALSE;
 
                if ($this->pObj->security_level == 'rsa' && t3lib_extMgm::isLoaded('rsaauth')) {
-                       require_once(t3lib_extMgm::extPath('rsaauth') . 'sv1/backends/class.tx_rsaauth_backendfactory.php');
-                       require_once(t3lib_extMgm::extPath('rsaauth') . 'sv1/storage/class.tx_rsaauth_storagefactory.php');
-
                        $backend = tx_rsaauth_backendfactory::getBackend();
                        $storage = tx_rsaauth_storagefactory::getStorage();
                                // Preprocess the password
@@ -242,41 +239,23 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                                );
                        }
 
-                       if (!$validPasswd && (intval($this->extConf['onlyAuthService']) || $this->authenticationFailed)) {
-                                       // Failed login attempt (wrong password) - no delegation to further services
+                       if (!$validPasswd) {
+                                       // Failed login attempt (wrong password)
                                $errorMessage = 'Login-attempt from %s (%s), username \'%s\', password not accepted!';
-                               $this->writeLogMessage(
-                                       TYPO3_MODE . ' Authentication failed - wrong password for username \'%s\'',
-                                       $this->login['uname']
-                               );
-                               $this->writelog(255, 3, 3, 1,
-                                       $errorMessage,
-                                       array(
-                                               $this->authInfo['REMOTE_ADDR'],
-                                               $this->authInfo['REMOTE_HOST'],
+                                       // no delegation to further services
+                               if (intval($this->extConf['onlyAuthService']) || $this->authenticationFailed) {
+                                       $this->writeLogMessage(
+                                               TYPO3_MODE . ' Authentication failed - wrong password for username \'%s\'',
                                                $this->login['uname']
-                                       )
-                               );
-                               t3lib_div::sysLog(
-                                       sprintf(
+                                       );
+                               } else {
+                                       $this->writeLogMessage(
                                                $errorMessage,
                                                $this->authInfo['REMOTE_ADDR'],
                                                $this->authInfo['REMOTE_HOST'],
                                                $this->login['uname']
-                                       ),
-                                       'Core',
-                                       0
-                               );
-                               $OK = 0;
-                       } elseif(!$validPasswd) {
-                                       // Failed login attempt (wrong password)
-                               $errorMessage = 'Login-attempt from %s (%s), username \'%s\', password not accepted!';
-                               $this->writeLogMessage(
-                                       $errorMessage,
-                                       $this->authInfo['REMOTE_ADDR'],
-                                       $this->authInfo['REMOTE_HOST'],
-                                       $this->login['uname']
-                               );
+                                       );
+                               }
                                $this->writelog(255, 3, 3, 1,
                                        $errorMessage,
                                        array(
@@ -295,6 +274,9 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
                                        'Core',
                                        0
                                );
+                               if (intval($this->extConf['onlyAuthService']) || $this->authenticationFailed) {
+                                       $OK = 0;
+                               }
                        } elseif ($validPasswd && $user['lockToDomain'] && strcasecmp($user['lockToDomain'], $this->authInfo['HTTP_HOST'])) {
                                        // Lock domain didn't match, so error:
                                $errorMessage = 'Login-attempt from %s (%s), username \'%s\', locked domain \'%s\' did not match \'%s\'!';