<?php
/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
// 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 {
{
$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);
}
$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);
}
// Renders the main XRDS 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);
// Renders the XRDS page of |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);
{
if ($response) {
$web_response = $this->server->encodeResponse($response);
- header(sprintf('HTTP/1.1 %d', $web_response->code), true, $web_response->code);
-
- foreach ($web_response->headers as $key => $value) {
- header(sprintf('%s: %s', $key, $value));
+ header(sprintf('%s %d', $_SERVER['SERVER_PROTOCOL'], $web_response->code),
+ true, $web_response->code);
+
+ 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;
}