]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
set identity and remove error_logs.
authorPablo Martin <caedes@sindominio.net>
Mon, 5 Nov 2012 08:27:02 +0000 (08:27 +0000)
committerroot <root@ops.vz.lan>
Mon, 5 Nov 2012 08:27:10 +0000 (08:27 +0000)
actions/trust.php

index 10b83127d9d34f8926d7af9dc0827838857d2b71..3f882125def8547252a76b3e051dbb54ac42bf52 100755 (executable)
@@ -10,7 +10,7 @@
  * @link http://elgg.org/\r
  */\r
  \r
-error_log("in trust.php");\r
+//error_log("in trust.php");\r
 \r
 require_once(dirname(dirname(__FILE__)).'/openid_server_include.php');\r
 \r
@@ -21,7 +21,7 @@ $info = getRequestInfo();
 $trusted = get_input('trust');\r
 $remember = get_input('remember');\r
 $trust_root = get_input('trust_root');\r
-error_log("in trust.php, getting store".$info->trust_root);\r
+\r
 $store = getOpenIDServerStore();\r
 if ($remember) {\r
       $store->setTrustedSite($info);\r
@@ -30,14 +30,15 @@ if ($remember) {
 \r
 if (!$info) {\r
         // There is no authentication information, so bail\r
-        error_log("in trust.php, no info");\r
         system_message(elgg_echo("openid_server:cancelled"));\r
         forward();\r
 } else {\r
 \r
     if ($idpSelect = $info->idSelect()) {\r
         if ($idpSelect) {\r
-            $req_url = idURL($idpSelect);\r
+           $identity = getLoggedInUser();\r
+            //$req_url = idURL($idpSelect);\r
+           $req_url = $info->identity;\r
            //XXX fixing dirty https stuff\r
            //$req_url = str_replace('http', 'https', $req_url);\r
         } else {\r
@@ -45,44 +46,32 @@ if (!$info) {
         }\r
     } else {\r
         $req_url = normaliseUsername($info->identity);\r
-       //XXX fixing dirty https stuff\r
-       //$req_url = str_replace('http', 'https', $req_url);\r
     }\r
     \r
-    error_log("in trust.php, getLoggedInUser");\r
     \r
     $user = getLoggedInUser();\r
-    error_log("in trust.php, setRequestInfo");\r
+    $identity = $user;\r
+\r
     setRequestInfo($info);\r
-    $user = str_replace('https', 'http', $user);\r
     $req_url_path = substr($req_url, strpos($req_url, ":"));\r
     $user_path = substr($user, strpos($user, ":"));\r
-    if ($req_url_path != $user_path) {\r
+\r
+    if ($info->message->isOpenID1() && $req_url_path != $user_path) {\r
         register_error(sprintf(elgg_echo("openid_server:loggedin_as_wrong_user"),$req_url, $user));\r
         forward();\r
     } else {\r
-    \r
         $trust_root = $info->trust_root;\r
-       //XXX fixing dirty https stuff\r
-        error_log("in trust.php, trust_root = $trust_root");\r
-        \r
-        $trusted = isset($trusted) ? $trusted : isTrusted($req_url,$trust_root);\r
+        $trusted = isset($trusted) ? $trusted : isTrusted($identity, $trust_root);\r
         if ($trusted) {\r
             setRequestInfo();\r
             $server =& getServer();\r
-            $response =& $info->answer(true, null, $req_url);\r
+           if ($info->message->isOpenID1())\r
+                   $response =& $info->answer(true, null, $req_url);\r
+           else\r
+                   $response =& $info->answer(true, null, getServerURL(), $identity);\r
             \r
-            error_log("in trust.php, addSregFields");\r
-       \r
-           //XXX this call gives fatal error: call to a member function isOpenID1()\r
-           //on a non-object (OpenID/Extension.php \r
-            addSregFields($response, $info, $req_url);\r
-//            error_log("in trust.php, response = " . print_r($response));\r
-            error_log("in trust.php, encodeResponse");\r
-            //XXX falla encoding de esta respuesta \r
+            addSregFields($response, $info, $identity);\r
             $webresponse =& $server->encodeResponse($response);\r
-            \r
-            error_log('in trust.php, webresponse ='.print_r($webresponse,true));\r
         \r
             $new_headers = array();\r
         \r
@@ -91,6 +80,7 @@ if (!$info) {
             }\r
         \r
             writeResponse( array($new_headers, $webresponse->body));\r
+           exit(0);\r
         } elseif ($fail_cancels) {\r
             setRequestInfo();\r
             forward($info->getCancelURL());\r