[FEATURE] New login error hook
authorSimon Schaufelberger <simonschaufi@googlemail.com>
Tue, 8 Nov 2011 19:19:20 +0000 (20:19 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Thu, 24 May 2012 05:54:50 +0000 (07:54 +0200)
Add new login hook to handle login errors.

Change-Id: I72b91b78955e27e4123f458e4bf6c50ab150397b
Resolves: #29698
Releases: 6.0
Reviewed-on: http://review.typo3.org/6600
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
typo3/sysext/felogin/pi1/class.tx_felogin_pi1.php

index 1dab737..dd24c3b 100644 (file)
@@ -70,7 +70,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                $this->pi_initPIflexForm();
                $this->mergeflexFormValuesIntoConf();
 
-
                        // Get storage PIDs:
                if ($this->conf['storagePid']) {
                        if (intval($this->conf['recursive'])) {
@@ -160,7 +159,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                }
 
                return $this->conf['wrapContentInBaseClass'] ? $this->pi_wrapInBaseClass($content) : $content;
-
        }
 
        /**
@@ -179,7 +177,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                        $postedHash = $postData['forgot_hash'];
                        $hashData = $GLOBALS['TSFE']->fe_user->getKey('ses', 'forgot_hash');
 
-
                        if ($postedHash === $hashData['forgot_hash']) {
                                $row = FALSE;
 
@@ -210,8 +207,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                                        $markerArray['###STATUS_MESSAGE###'] = $this->cObj->stdWrap($this->pi_getLL('ll_forgot_reset_message_emailSent', '', 1), $this->conf['forgotResetMessageEmailSentMessage_stdWrap.']);
                                }
                                $subpartArray['###FORGOT_FORM###'] = '';
-
-
                        } else {
                                        //wrong email
                                $markerArray['###STATUS_MESSAGE###'] = $this->getDisplayText('forgot_reset_message', $this->conf['forgotMessage_stdWrap.']);
@@ -224,18 +219,14 @@ class tx_felogin_pi1 extends tslib_pibase {
 
                $markerArray['###BACKLINK_LOGIN###'] = $this->getPageLink($this->pi_getLL('ll_forgot_header_backToLogin', '', 1), array());
                $markerArray['###STATUS_HEADER###'] = $this->getDisplayText('forgot_header', $this->conf['forgotHeader_stdWrap.']);
-
                $markerArray['###LEGEND###'] = $this->pi_getLL('legend', $this->pi_getLL('reset_password', '', 1), 1);
                $markerArray['###ACTION_URI###'] = $this->getPageLink('', array($this->prefixId . '[forgot]'=>1), TRUE);
                $markerArray['###EMAIL_LABEL###'] = $this->pi_getLL('your_email', '', 1);
                $markerArray['###FORGOT_PASSWORD_ENTEREMAIL###'] = $this->pi_getLL('forgot_password_enterEmail', '', 1);
                $markerArray['###FORGOT_EMAIL###'] = $this->prefixId.'[forgot_email]';
                $markerArray['###SEND_PASSWORD###'] = $this->pi_getLL('reset_password', '', 1);
-
                $markerArray['###DATA_LABEL###'] = $this->pi_getLL('ll_enter_your_data', '', 1);
 
-
-
                $markerArray = array_merge($markerArray, $this->getUserFieldMarkers());
 
                        // generate hash
@@ -244,7 +235,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                        // set hash in feuser session
                $GLOBALS['TSFE']->fe_user->setKey('ses', 'forgot_hash', array('forgot_hash' => $hash));
 
-
                return $this->cObj->substituteMarkerArrayCached($subpart, $markerArray, $subpartArray, $linkpartArray);
        }
 
@@ -478,7 +468,7 @@ class tx_felogin_pi1 extends tslib_pibase {
                                        // Hook for general actions after after login has been confirmed (by Thomas Danzl <thomas@danzl.org>)
                                if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_confirmed']) {
                                        $_params = array();
-                                       foreach($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_confirmed'] as $_funcRef) {
+                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_confirmed'] as $_funcRef) {
                                                if ($_funcRef) {
                                                        t3lib_div::callUserFunction($_funcRef, $_params, $this);
                                                }
@@ -490,6 +480,16 @@ class tx_felogin_pi1 extends tslib_pibase {
                                        return $this->showLogout();
                                }
                        } else {
+                                       // Hook for general actions on login error
+                               if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_error']) &&
+                                       is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_error'])) {
+                                       $params = array();
+                                       foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['login_error'] as $funcRef) {
+                                               if ($funcRef) {
+                                                       t3lib_div::callUserFunction($funcRef, $params, $this);
+                                               }
+                                       }
+                               }
                                        // login error
                                $markerArray['###STATUS_HEADER###'] = $this->getDisplayText('error_header',$this->conf['errorHeader_stdWrap.']);
                                $markerArray['###STATUS_MESSAGE###'] = $this->getDisplayText('error_message',$this->conf['errorMessage_stdWrap.']);
@@ -507,7 +507,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                        }
                }
 
-
                        // Hook (used by kb_md5fepw extension by Kraft Bernhard <kraftb@gmx.net>)
                        // This hook allows to call User JS functions.
                        // The methods should also set the required JS functions to get included
@@ -567,7 +566,6 @@ class tx_felogin_pi1 extends tslib_pibase {
                        $subpartArray['###FORGOTP_VALID###'] = '';
                }
 
-
                        // The permanent login checkbox should only be shown if permalogin is not deactivated (-1), not forced to be always active (2) and lifetime is greater than 0
                if ($this->conf['showPermaLogin'] && t3lib_div::inList('0,1', $GLOBALS['TYPO3_CONF_VARS']['FE']['permalogin']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['lifetime'] > 0) {
                        $markerArray['###PERMALOGIN###'] = $this->pi_getLL('permalogin', '', 1);
@@ -712,14 +710,13 @@ class tx_felogin_pi1 extends tslib_pibase {
                                                break;
                                        }
                                }
-
-                               }
                        }
-                               // remove empty values
-                       if (count($redirect_url)) {
-                               return t3lib_div::trimExplode(',', implode(',', $redirect_url), TRUE);
-                       } else {
-                               return array();
+               }
+                       // remove empty values
+               if (count($redirect_url)) {
+                       return t3lib_div::trimExplode(',', implode(',', $redirect_url), TRUE);
+               } else {
+                       return array();
                }
        }
 
@@ -1009,4 +1006,4 @@ class tx_felogin_pi1 extends tslib_pibase {
                return FALSE;
        }
 }
-?>
+?>
\ No newline at end of file