[FEATURE] Change the way saltedpasswords sets "eval" in ext_tables.php
authorLaurent Cherpit <laurent.cherpit@gmail.com>
Tue, 26 Jul 2011 16:20:42 +0000 (18:20 +0200)
committerXavier Perseguers <xavier@typo3.org>
Sun, 31 Jul 2011 11:13:22 +0000 (13:13 +0200)
For the TCA password fields (BE|FE), saltedpasswords overrides the
field used to add some evaluations method. The problem appears when
another evaluation method is added before saltedpasswords extension is
loaded.
Change the way of the available evaluations methods are added by
saltedpasswords.

Change-Id: Ibcc13da492736891937fefbf9e323338229fb1dc
Resolves: #28494
Releases: 4.6
Reviewed-on: http://review.typo3.org/3725
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/saltedpasswords/ext_tables.php

index 3ea2bec..df0ccc7 100644 (file)
@@ -3,18 +3,44 @@ if (!defined ('TYPO3_MODE')) {
        die ('Access denied.');
 }
 
+
 t3lib_div::loadTCA('fe_users');
-$TCA['fe_users']['columns']['password']['config']['max'] = 60;
+$GLOBALS['TCA']['fe_users']['columns']['password']['config']['max'] = 60;
 
 if (tx_saltedpasswords_div::isUsageEnabled('FE')) {
-       $TCA['fe_users']['columns']['password']['config']['eval'] = 'trim,required,tx_saltedpasswords_eval_fe,password';
+
+               // Get eval field operations methods as array keys
+       $operations = array_flip(t3lib_div::trimExplode(',', $GLOBALS['TCA']['fe_users']['columns']['password']['config']['eval'], TRUE));
+
+               // Remove md5 and temporary password from the list of evaluated methods
+       unset($operations['md5'], $operations['password']);
+
+               // Append new methods to have "password" as last operation.
+       $operations['tx_saltedpasswords_eval_fe'] = 1;
+       $operations['password'] = 1;
+
+       $GLOBALS['TCA']['fe_users']['columns']['password']['config']['eval'] = implode(',', array_keys($operations));
+       unset($operations);
 }
 
+
 t3lib_div::loadTCA('be_users');
-$TCA['be_users']['columns']['password']['config']['max'] = 60;
+$GLOBALS['TCA']['be_users']['columns']['password']['config']['max'] = 60;
 
 if (tx_saltedpasswords_div::isUsageEnabled('BE')) {
-       $TCA['be_users']['columns']['password']['config']['eval'] = 'trim,required,tx_saltedpasswords_eval_be,password';
+
+               // Get eval field operations methods as array keys
+       $operations = array_flip(t3lib_div::trimExplode(',', $GLOBALS['TCA']['be_users']['columns']['password']['config']['eval'], TRUE));
+
+               // Remove md5 and temporary password from the list of evaluated methods
+       unset($operations['md5'], $operations['password']);
+
+               // Append new methods to have "password" as last operation.
+       $operations['tx_saltedpasswords_eval_be'] = 1;
+       $operations['password'] = 1;
+
+       $GLOBALS['TCA']['be_users']['columns']['password']['config']['eval'] = implode(',', array_keys($operations));
+       unset($operations);
 
                // Prevent md5 hashing on client side via JS
        $GLOBALS['TYPO3_USER_SETTINGS']['columns']['password']['eval'] = '';