[BUGFIX] Improve "Sign in with Twitter" process 34/26734/2
authorNicole Cordes <cordes@cps-it.de>
Fri, 10 Jan 2014 11:09:44 +0000 (12:09 +0100)
committerNicole Cordes <typo3@cordes.co>
Mon, 13 Jan 2014 08:29:01 +0000 (09:29 +0100)
The patch adds support for TYPO3 installations in subfolders and
corrects the submitted return url. Additionally the javascript was
improved to fill in retrieved token information automatically.

Change-Id: I79749209a081b4066c2db568edff12320a607b4a
Reviewed-on: https://review.typo3.org/26734
Reviewed-by: Nicole Cordes
Tested-by: Nicole Cordes
Classes/Twitter/Redirect.php
Classes/Twitter/SignIn.php

index ad5d5a2..6d5214f 100644 (file)
@@ -91,12 +91,14 @@ if (!empty($_GET['oauth_token']) && !empty($_GET['oauth_verifier'])) {
                        oAuthTokenObject = parent.window.opener.document.configurationform["tx_extensionmanager_tools_extensionmanagerextensionmanager[config][oauth_token][value]"];
                        oAuthTokenSecretObject = parent.window.opener.document.configurationform["tx_extensionmanager_tools_extensionmanagerextensionmanager[config][oauth_token_secret][value]"];
                } else {
-                       if (parent.window.opener.document.forms &&
-                               parent.window.opener.document.forms[parent.window.opener.document.forms.length - 1] &&
-                               parent.window.opener.document.forms[parent.window.opener.document.forms.length - 1]["data[oauth_token]"] &&
-                               parent.window.opener.document.forms[parent.window.opener.document.forms.length - 1]["data[oauth_token_secret]"]) {
-                               oAuthTokenObject = parent.window.opener.document.forms[parent.window.opener.document.forms.length - 1]["data[oauth_token]"];
-                               oAuthTokenSecretObject = parent.window.opener.document.forms[parent.window.opener.document.forms.length - 1]["data[oauth_token_secret]"];
+                       if (parent.window.opener.document.forms) {
+                               for (i=0; i<parent.window.opener.document.forms.length; i++) {
+                                       if (typeof parent.window.opener.document.forms[i]["data[oauth_token]"] != "undefined") {
+                                               oAuthTokenObject = parent.window.opener.document.forms[i]["data[oauth_token]"];
+                                               oAuthTokenSecretObject = parent.window.opener.document.forms[i]["data[oauth_token_secret]"];
+                                               break;
+                                       }
+                               }
                        }
                }
                if (oAuthTokenObject != "" && oAuthTokenSecretObject != "") {
@@ -104,10 +106,9 @@ if (!empty($_GET['oauth_token']) && !empty($_GET['oauth_verifier'])) {
                                        echo 'oAuthTokenObject.value = "' . $oAuthToken . '";';
                                        echo 'oAuthTokenSecretObject.value = "' . $oAuthTokenSecret . '";';
                        ?>
-
+                       parent.window.opener.focus();
+                       parent.close();
                }
-               parent.window.opener.focus();
-               parent.close();
        }
 </script>
 
index 5b30304..d80c4c1 100644 (file)
@@ -56,8 +56,8 @@ class Tx_WtTwitter_Twitter_SignIn {
                                        Tx_WtTwitter_Twitter_Api::getOAuthParameter(
                                                '',
                                                array(
-                                                       'oauth_callback' => 'http://' . t3lib_div::getIndpEnv('HTTP_HOST') . '/' .
-                                                       t3lib_extMgm::siteRelPath('wt_twitter') . 'Classes/Twitter/Redirect.php'
+                                                       'oauth_callback' => t3lib_div::getIndpEnv('TYPO3_SITE_URL') .
+                                                               t3lib_extMgm::siteRelPath('wt_twitter') . 'Classes/Twitter/Redirect.php'
                                                )
                                        ),
                                        $url,