X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fopenid%2Fopenid.inc.php;h=0b7dc639520ac4d2fe937a871aa2ed3d33e00d80;hb=07c1b4bc8ebf1ec9d358ec8897a89287378acd63;hp=455e9df2525c48d8c60a1b6f3aecc67868afadee;hpb=d1e6167749fdad08c81e23d09e1bbbf76e3b989b;p=platal.git diff --git a/modules/openid/openid.inc.php b/modules/openid/openid.inc.php index 455e9df..0b7dc63 100644 --- a/modules/openid/openid.inc.php +++ b/modules/openid/openid.inc.php @@ -1,6 +1,6 @@ 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 { @@ -137,8 +138,8 @@ class OpenId { $res = XDB::query( "SELECT COUNT(*) - FROM openid_trusted - WHERE (user_id = {?} OR user_id IS NULL) AND url = {?}", + FROM account_auth_openid + WHERE (uid = {?} OR uid IS NULL) AND url = {?}", $user->id(), $this->request->trust_root); return ($res->fetchOneCell() > 0); } @@ -146,12 +147,12 @@ class OpenId // Updates the trust level for the given endpoint, based on the value pf // |trusted| and |permanent_trust| (the latter is ignored when the former // value is false). Returns true iff the current endpoint is trusted. - public function UpdateEndpointTrust(User &$user, $trusted, $permanent_trust) { + public function UpdateEndpointTrust(User $user, $trusted, $permanent_trust) { $initial_trust = $this->IsEndpointTrusted($user); if (!$initial_trust && $trusted && $permanent_trust) { XDB::execute( - "INSERT IGNORE INTO openid_trusted - SET user_id = {?}, url = {?}", + "INSERT IGNORE INTO account_auth_openid + SET uid = {?}, url = {?}", $user->id(), $this->request->trust_root); } @@ -161,7 +162,7 @@ class OpenId // Page renderers ---------------------------------------------------------- // Renders the OpenId discovery page for |user|. - public function RenderDiscoveryPage(&$page, User &$user) + public function RenderDiscoveryPage($page, User $user) { $page->changeTpl('openid/openid.tpl'); $page->setTitle($user->fullName()); @@ -174,9 +175,9 @@ class OpenId } // Renders the main XRDS page. - public function RenderMainXrdsPage(&$page) + public function RenderMainXrdsPage($page) { - header('Content-type: application/xrds+xml'); + pl_content_headers("application/xrds+xml"); $page->changeTpl('openid/idp_xrds.tpl', NO_SKIN); $page->assign('type2', Auth_OpenID_TYPE_2_0_IDP); $page->assign('sreg', Auth_OpenID_SREG_URI); @@ -184,9 +185,9 @@ class OpenId } // Renders the XRDS page of |user|. - public function RenderUserXrdsPage(&$page, User &$user) + public function RenderUserXrdsPage($page, User $user) { - header('Content-type: application/xrds+xml'); + pl_content_headers("application/xrds+xml"); $page->changeTpl('openid/user_xrds.tpl', NO_SKIN); $page->assign('type2', Auth_OpenID_TYPE_2_0); $page->assign('type1', Auth_OpenID_TYPE_1_1); @@ -203,12 +204,16 @@ class OpenId header(sprintf('%s %d', $_SERVER['SERVER_PROTOCOL'], $web_response->code), true, $web_response->code); - foreach ($web_response->headers as $key => $value) { - header(sprintf('%s: %s', $key, $value)); - } + 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; } @@ -216,13 +221,13 @@ class OpenId // URL providers ----------------------------------------------------------- // Returns the OpenId identity URL of the requested user. - private function GetUserUrl(User &$user) + private function GetUserUrl(User $user) { return $this->base_url . '/' . $user->login(); } // Returns the private XRDS page of a user. - private function GetUserXrdsUrl(User &$user) + private function GetUserXrdsUrl(User $user) { return $this->base_url . '/xrds/' . $user->login(); }