Finally fixes the OpenID authentication for Facebook by always adding the user inform...
authorVincent Zanotti <vincent.zanotti@m4x.org>
Thu, 30 Jul 2009 18:44:44 +0000 (20:44 +0200)
committerVincent Zanotti <vincent.zanotti@m4x.org>
Thu, 30 Jul 2009 18:45:38 +0000 (20:45 +0200)
Also fixes the error display.

Signed-off-by: Vincent Zanotti <vincent.zanotti@m4x.org>
modules/openid.php
modules/openid/openid.inc.php

index 6b8f031..574b1bf 100644 (file)
@@ -197,8 +197,7 @@ class OpenidModule extends PLModule
 
         // Finally answers the request.
         if ($server->IsUserAuthorized($user) && $trusted) {
-            $server->AnswerRequest(
-                true, $user, Post::b('trust_sreg') ? $sreg_response : null);
+            $server->AnswerRequest(true, Post::b('trust_sreg') ? $sreg_response : null);
         } else {
             $server->AnswerRequest(false);
         }
index ba70f2f..c8c5bf7 100644 (file)
@@ -106,10 +106,11 @@ class OpenId
 
     // Answers the current request, and renders the response. Appends the |sreg|
     // data when not null.
-    public function AnswerRequest($is_authorized, $user = null, $sreg_data = null)
+    public function AnswerRequest($is_authorized, $sreg_data = null)
     {
         // Creates the response.
-        if ($is_authorized && $this->request->idSelect() && $user) {
+        if ($is_authorized && $this->request->idSelect()) {
+            $user = S::user();
             $response = $this->request->answer(
                 $is_authorized, null, $user->login(), $this->GetUserUrl($user));
         } else {
@@ -203,14 +204,16 @@ class OpenId
             header(sprintf('%s %d', $_SERVER['SERVER_PROTOCOL'], $web_response->code),
                    true, $web_response->code);
 
-            if (count($web_response->headers) > 0) {
+            if (is_a($response, 'Auth_OpenID_ServerError')) {
+                print "Erreur lors de l'authentification OpenId: " . $response->toString();
+            } else {
                 foreach ($web_response->headers as $key => $value) {
                     header(sprintf('%s: %s', $key, $value));
                 }
-            }
 
-            header('Connection: close');
-            print $web_response->body;
+                header('Connection: close');
+                print $web_response->body;
+            }
         }
         exit;
     }