simplify auth mechanism a bit more
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 19 Jul 2006 06:35:59 +0000 (06:35 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 19 Jul 2006 06:35:59 +0000 (06:35 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@541 839d8a87-29fc-0310-9880-83ba4fa771e5

classes/Platal.php
include/xnet/page.inc.php
include/xnet/session.inc.php
include/xorg.inc.php
include/xorg/session.inc.php
plugins/pmwiki.platalAuth.php

index f5553f8..056ae80 100644 (file)
@@ -86,7 +86,7 @@ class Platal
 
         if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
             // FIXME: don't use 'session' object anymore
-            $_SESSION['session']->doAuth($page);
+            $_SESSION['session']->doAuth();
         }
 
         return call_user_func_array($hook['hook'], $args);
index a1af5e5..cf3df33 100644 (file)
@@ -113,14 +113,19 @@ class XnetPage extends PlatalPage
         $this->register_modifier('cat_pp', 'cat_pp');
         $this->assign('it_is_xnet', true);
         if (!S::logged() && $force) {
-            XnetSession::doLogin($this);
+            XnetSession::doAuth();
         }
         if (!S::logged() && Get::has('auth')) {
-            XnetSession::doAuthX($this);
+            XnetSession::doAuthX();
         }
     }
 
     // }}}
+
+    function doLogin()
+    {
+        redirect(S::v('loginX'));
+    }
 }
 
 // }}}
index 83e3a72..c0b6d26 100644 (file)
@@ -21,8 +21,6 @@
 
 require_once('platal/session.inc.php');
 
-// {{{ class XorgSession
-
 class XnetSession
 {
     // {{{ function init
@@ -64,24 +62,26 @@ class XnetSession
      *
      * @param page the calling page (by reference)
      */
-    function doAuth(&$page)
+    function doAuth()
     {
        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
            return true;
        }
 
         if (Get::has('auth')) {
-            return XnetSession::doAuthX($page);
+            return XnetSession::doAuthX();
         } else {
-            XnetSession::doLogin($page);
+            global $page;
+
+            $page->doLogin();
         }
     }
 
     // }}}
     // {{{ doAuthX
 
-    function doAuthX(&$page) {
-        global $globals;
+    function doAuthX() {
+        global $globals, $page;
 
         if (md5('1'.S::v('challenge').$globals->xnet->secret.Get::getInt('uid').'1') != Get::get('auth')) {
             $page->kill("Erreur d'authentification avec polytechnique.org !");
@@ -103,23 +103,18 @@ class XnetSession
         Get::kill('auth');
         Get::kill('uid');
         $args = array();
-        foreach($_GET as $key=>$val) {
+        $path = Get::get('p');
+        Get::kill('p');
+
+        foreach($_GET as $key => $val) {
             $args[] = urlencode($key).'='.urlencode($val);
         }
-        redirect($_SERVER['PHP_SELF'] . '?' . join('&', $args));
-    }
-
-    // }}}
-    // {{{ doLogin
-
-    function doLogin(&$page) {
-        redirect(S::v('loginX'));
+        redirect($globals->baseurl . '/' . $path . '?' . join('&', $args));
     }
 
     // }}}
 }
 
-// }}}
 // {{{ may_update
 
 function may_update() {
index 209de7c..3b9519c 100644 (file)
@@ -31,16 +31,11 @@ require_once('platal/page.inc.php');
 
 class XorgPage extends PlatalPage
 {
-    // {{{ function XorgPage()
-
     function XorgPage($tpl, $type=SKINNED)
     {
         $this->PlatalPage($tpl, $type);
     }
 
-    // }}}
-    // {{{ function run()
-
     function run()
     {
         global $globals;
@@ -50,7 +45,18 @@ class XorgPage extends PlatalPage
         $this->_run('skin/'.S::v('skin'));
     }
 
-    // }}}
+    function doLogin($new_name = false)
+    {
+        global $page;
+        if (S::logged() and !$new_name) {
+            $page->changeTpl('password_prompt_logged.tpl');
+            $page->addJsLink('javascript/do_challenge_response_logged.js');
+        } else {
+            $page->changeTpl('password_prompt.tpl');
+            $page->addJsLink('javascript/do_challenge_response.js');
+       }
+        $page->run();
+    }
 }
 
 // }}}
index 9d783e2..96382fe 100644 (file)
@@ -51,7 +51,7 @@ class XorgSession
      *
      * @param page the calling page (by reference)
      */
-    function doAuth(&$page,$new_name=false)
+    function doAuth($new_name = false)
     {
        global $globals;
        if (S::identified()) { // ok, c'est bon, on n'a rien à faire
@@ -137,7 +137,9 @@ class XorgSession
                     $logger->log('auth_fail','bad login');
             }
        }
-        XorgSession::doLogin($page,$new_name);
+
+        global $page;
+        $page->doLogin($new_name);
     }
 
     // }}}
@@ -154,45 +156,15 @@ class XorgSession
         }
 
        if (Env::has('username') and Env::has('response')) {
-           return XorgSession::doAuth($page);
+           return XorgSession::doAuth();
         }
 
        if ($r = try_cookie()) {
-           return XorgSession::doAuth($page,($r>0));
+           return XorgSession::doAuth(($r > 0));
         }
     }
 
     // }}}
-    // {{{ function doLogin()
-
-    /** Display login screen.
-     */
-    function doLogin(&$page, $new_name=false)
-    {
-        if (S::logged() and !$new_name) {
-            $page->changeTpl('password_prompt_logged.tpl');
-            $page->addJsLink('javascript/do_challenge_response_logged.js');
-            $page->assign("xorg_tpl", "password_prompt_logged.tpl");
-            $page->run();
-        } else {
-            $page->changeTpl('password_prompt.tpl');
-            $page->addJsLink('javascript/do_challenge_response.js');
-            $page->assign("xorg_tpl", "password_prompt.tpl");
-
-            global $globals;
-            if ($globals->mail->alias_dom) {
-                $page->assign("domains", Array(
-                    $globals->mail->domain."/".$globals->mail->domain2,
-                    $globals->mail->alias_dom."/".$globals->mail->alias_dom2));
-                $page->assign("domains_value", Array("login", "alias"));
-                $page->assign("r_domain", Cookie::get('ORGdomain', 'login'));
-            }
-           $page->run();
-       }
-       exit;
-    }
-
-    // }}}
 }
 
 // }}}
index f5a7831..646d3be 100644 (file)
@@ -162,10 +162,10 @@ function AuthPlatal($pagename, $level, $authprompt, $since)
     // maybe it is because he is not identified
     if ($authprompt && !S::identified())
     {
-        XorgSession::doAuth($page);
+        XorgSession::doAuth();
     }
 
-    XorgSession::doAuth($page);
+    XorgSession::doAuth();
     if (S::has_perms()) {
         $page->trig('Erreur : page Wiki inutilisable sur plat/al');
     } else {