[BUGFIX] Removed dependency on TYPO3_MODE in saltedpasswords
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Thu, 28 Apr 2011 13:53:28 +0000 (15:53 +0200)
committerDmitry Dulepov <dmitry@typo3.org>
Thu, 6 Oct 2011 07:37:34 +0000 (09:37 +0200)
Removed dependency on TYPO3_MODE constant in saltedpasswords which was
used to determine if the extension is enabled and which table (fe_users
or be_users) should be updated.

Since the mode is required in the init process of saltedpasswords where
the parent auth object is not available the new data in the info
array (introduced in #26410) is used.

Change-Id: I04180d283d6818b2e09d33f82036f6f88a5cb26c
Resolves: #22881
Reviewed-on: http://review.typo3.org/1778
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Reviewed-by: Steffen Ritter
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
typo3/sysext/saltedpasswords/sv1/class.tx_saltedpasswords_sv1.php

index 6e16397..8600e57 100644 (file)
@@ -97,7 +97,15 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
        public function init() {
                $available = FALSE;
 
-               if (tx_saltedpasswords_div::isUsageEnabled()) {
+               $mode = TYPO3_MODE;
+               if ($this->info['requestedServiceSubType'] === 'authUserBE') {
+                       $mode = 'BE';
+               }
+               elseif ($this->info['requestedServiceSubType'] === 'authUserFE') {
+                       $mode = 'FE';
+               }
+
+               if (tx_saltedpasswords_div::isUsageEnabled($mode)) {
                        $available = TRUE;
                        $this->extConf = tx_saltedpasswords_div::returnExtConf();
                }
@@ -331,13 +339,8 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
         * @return      void
         */
        protected function updatePassword($uid, $updateFields) {
-               if (TYPO3_MODE === 'BE') {
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery( 'be_users', sprintf('uid = %u', $uid), $updateFields);
-               } else {
-                       $GLOBALS['TYPO3_DB']->exec_UPDATEquery( 'fe_users', sprintf('uid = %u', $uid), $updateFields);
-               }
-
-               t3lib_div::devLog(sprintf('Automatic password update for %s user with uid %u', TYPO3_MODE, $uid), $this->extKey, 1);
+               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->pObj->user_table, sprintf('uid = %u', $uid), $updateFields);
+               t3lib_div::devLog(sprintf('Automatic password update for user record in %s with uid %u', $this->pObj->user_table, $uid), $this->extKey, 1);
        }
 
        /**
@@ -379,4 +382,4 @@ class tx_saltedpasswords_sv1 extends tx_sv_authbase {
 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/saltedpasswords/sv1/class.tx_saltedpasswords_sv1.php'])) {
        include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/saltedpasswords/sv1/class.tx_saltedpasswords_sv1.php']);
 }
-?>
\ No newline at end of file
+?>