From 80c1ab911f57523602bd7584fd764686d2cc0762 Mon Sep 17 00:00:00 2001 From: Vincent Zanotti Date: Thu, 30 Jul 2009 20:44:44 +0200 Subject: [PATCH] Finally fixes the OpenID authentication for Facebook by always adding the user information in an IdP-identity-select request. Also fixes the error display. Signed-off-by: Vincent Zanotti --- modules/openid.php | 3 +-- modules/openid/openid.inc.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/openid.php b/modules/openid.php index 6b8f031..574b1bf 100644 --- a/modules/openid.php +++ b/modules/openid.php @@ -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); } diff --git a/modules/openid/openid.inc.php b/modules/openid/openid.inc.php index ba70f2f..c8c5bf7 100644 --- a/modules/openid/openid.inc.php +++ b/modules/openid/openid.inc.php @@ -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; } -- 2.1.4