[BUGFIX] Wrong link if felogin reset password
authorFrancois Suter <francois@typo3.org>
Wed, 22 Jun 2011 14:14:35 +0000 (16:14 +0200)
committerFrancois Suter <francois@typo3.org>
Fri, 5 Aug 2011 07:44:20 +0000 (09:44 +0200)
When the reset password link for felogin is generated (to be sent in
the mail), config.absRefPrefix overrides
plugin.tx_felogin_pi1.feloginBaseURL, but feloginBaseURL is specifically
designed to be used when needing a different base URL. This patch
makes feloginBaseURL prevail.

Thanks to Stephan Bauer for the original patch.

Change-Id: I05e3e63a3ad4628e07396e2dd8f089cd18dfc7f9
Resolves: #22434
Releases: 4.6, 4.5
Reviewed-on: http://review.typo3.org/2878
Reviewed-by: Helmut Hummel
Reviewed-by: Markus Klein
Reviewed-by: Stefan Neufeind
Reviewed-by: Francois Suter
Tested-by: Francois Suter
typo3/sysext/felogin/pi1/class.tx_felogin_pi1.php

index e522a71..3c0697a 100644 (file)
@@ -349,26 +349,32 @@ class tx_felogin_pi1 extends tslib_pibase {
                $isBaseURL  = !empty($GLOBALS['TSFE']->baseUrl);
                $isFeloginBaseURL = !empty($this->conf['feloginBaseURL']);
 
+               $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', array(
+                       $this->prefixId . '[user]' => $user['uid'],
+                       $this->prefixId . '[forgothash]' => $randHash
+               ));
+
+                       // Prefix link if necessary
                if ($isFeloginBaseURL) {
-                               // first priority
-                       $this->conf['linkPrefix'] = $this->conf['feloginBaseURL'];
-               } else {
-                       if ($isBaseURL) {
-                                       // 3rd priority
-                               $this->conf['linkPrefix'] = $GLOBALS['TSFE']->baseUrl;
+                               // First priority, use specific base URL
+                               // "absRefPrefix" must be removed first, otherwise URL will be prepended twice
+                       if (!empty($GLOBALS['TSFE']->absRefPrefix)) {
+                               $link = substr($link, strlen($GLOBALS['TSFE']->absRefPrefix));
                        }
-               }
-
-               if ($this->conf['linkPrefix'] == -1 && !$isAbsRelPrefix) {
-                               // no preix is set, return the error
+                       $link = $this->conf['feloginBaseURL'] . $link;
+               } elseif ($isAbsRelPrefix) {
+                       // Second priority
+                       // absRefPrefix must not necessarily contain a hostname and URL scheme, so add it if needed
+                       $link = t3lib_div::locationHeaderUrl($link);
+               } elseif ($isBaseURL) {
+                               // Third priority
+                               // Add the global base URL to the link
+                       $link = $GLOBALS['TSFE']->baseUrlWrap($link);
+               } else {
+                               // no prefix is set, return the error
                        return $this->pi_getLL('ll_change_password_nolinkprefix_message');
                }
 
-               $link = ($isAbsRelPrefix ? '' : $this->conf['linkPrefix']) . $this->pi_getPageLink($GLOBALS['TSFE']->id, '', array(
-                       $this->prefixId . '[user]' => $user['uid'],
-                       $this->prefixId . '[forgothash]' => $randHash
-               ));
-
                $msg = sprintf($this->pi_getLL('ll_forgot_validate_reset_password', '', 0), $user['username'], $link, $validEndString);
 
                        // no RDCT - Links for security reasons