XnetSession inherits XorgSession.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 31 Aug 2008 16:45:23 +0000 (18:45 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 31 Aug 2008 16:45:23 +0000 (18:45 +0200)
Avoid code duplication.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/xnetsession.php

index 4a96f12..a1a6cf8 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-class XnetSession extends PlSession
+class XnetSession extends XorgSession
 {
     public function __construct()
     {
@@ -124,32 +124,6 @@ class XnetSession extends PlSession
         return true;
     }
 
-    public function tokenAuth($login, $token)
-    {
-        // FIXME: we broke the session here because some RSS feeds (mainly wiki feeds) require
-        // a valid nome and checks the permissions. When the PlUser object will be ready, we'll
-        // be able to return a simple 'PlUser' object here without trying to alterate the
-        // session.
-        $res = XDB::query('SELECT  u.user_id AS uid, u.perms, u.nom, u.nom_usage, u.prenom, u.promo, FIND_IN_SET(\'femme\', u.flags) AS sexe
-                             FROM  aliases         AS a
-                       INNER JOIN  auth_user_md5   AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
-                       INNER JOIN  auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
-                            WHERE  a.alias = {?} AND a.type != "homonyme"', $token, $login);
-        if ($res->numRows() == 1) {
-            $sess = $res->fetchOneAssoc();
-            if (!S::has('uid')) {
-                $_SESSION = $sess;
-                $this->makePerms($sess['perms']);
-                return S::i('uid');
-            } else if (S::i('uid') == $sess['uid']) {
-                return S::i('uid');
-            } else {
-                Platal::page()->kill('Invalid state. To be fixed when hruid is ready');
-            }
-        }
-        return null;
-    }
-
     public function doSelfSuid()
     {
         if (!$this->startSUID(S::i('uid'))) {
@@ -171,30 +145,6 @@ class XnetSession extends PlSession
         S::set('perms', $suid['perms']);
         return true;
     }
-
-    public function makePerms($perm)
-    {
-        $flags = new PlFlagSet();
-        if ($perm == 'disabled' || $perm == 'ext') {
-            S::set('perms', $flags);
-            return;
-        }
-        $flags->addFlag(PERMS_USER);
-        if ($perm == 'admin') {
-            $flags->addFlag(PERMS_ADMIN);
-        }
-        S::set('perms', $flags);
-    }
-
-    public function loggedLevel()
-    {
-        return AUTH_COOKIE;
-    }
-
-    public function sureLevel()
-    {
-        return AUTH_MDP;
-    }
 }
 
 // {{{ function may_update