Partial rewrite of auth.
[dotclear.git] / _public.php
1 <?php
2 $core->url->register('xorgAuth', 'Xorg', '^auth/(.*)$', array('xorgAuthentifier', 'doAuth'));
3
4 class xorgAuthWidget {
5 static public function widget(&$w) {
6 global $core;
7 if ($core->auth->xorg_infos['forlife']) {
8 return '<p>Tu es ' . $core->auth->xorg_infos['prenom'] . ' ' . $core->auth->xorg_infos['nom'] . '<br />'
9 . '<a href="auth/exit">déconnexion</a></p>';
10 } else {
11 return '<p><a href="auth/Xorg?path=' . $_SERVER['REQUEST_URI'] . '">M\'authentifier via Polytechnique.org</a></p>';
12 }
13 }
14 }
15
16 class xorgAuthentifier extends dcUrlHandlers {
17 static public function doAuth($args) {
18 global $core;
19 switch ($args) {
20 case 'exit':
21 $core->auth->killSession();
22 break;
23 case 'Xorg':
24 if ($core->auth->callXorg($_GET['path'])) {
25 header('Location: http://murphy.m4x.org' . $_GET['path']);
26 exit;
27 }
28 break;
29 case 'XorgReturn':
30 $core->auth->returnXorg();
31 break;
32 default:
33 self::p404();
34 }
35 return;
36 }
37
38 }
39 ?>