X.net authentication.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 23 Dec 2008 14:57:28 +0000 (15:57 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Tue, 23 Dec 2008 14:57:28 +0000 (15:57 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/platalglobals.php.in
classes/xnetsession.php

index 0528913..e4b1b94 100644 (file)
@@ -86,8 +86,8 @@ class PlatalGlobals extends PlGlobals
     public function updateNbIns()
     {
         $res = XDB::query("SELECT  COUNT(*)
-                             FROM  auth_user_md5
-                            WHERE  perms IN ('admin','user') AND deces=0");
+                             FROM  accounts
+                            WHERE  state = 'active'");
         $cnt = $res->fetchOneCell();
         $this->changeDynamicConfig(array('NbIns' => $cnt));
     }
index 6f44dbd..79e456a 100644 (file)
@@ -76,7 +76,7 @@ class XnetSession extends XorgSession
     protected function doAuth($level)
     {
         if (S::identified()) { // ok, c'est bon, on n'a rien à faire
-            return S::i('uid');
+            return User::getSilentWithValues(null, array('user_id' => S::i('uid')));
         }
         if (!Get::has('auth')) {
             return null;
@@ -87,25 +87,25 @@ class XnetSession extends XorgSession
         }
         Get::kill('auth');
         S::set('auth', AUTH_MDP);
-        return Get::i('uid');
+        return User::getSilentWithValues(null, array('user_id' => Get::i('uid')));
     }
 
     protected function startSessionAs($user, $level)
     {
-        if ($level == -1) {
+        if ($level == AUTH_SUID) {
             S::set('auth', AUTH_MDP);
         }
-        $res  = XDB::query("SELECT  u.user_id AS uid, u.hruid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme,
-                                    q.core_mail_fmt AS mail_fmt, q.core_rss_hash
-                              FROM  auth_user_md5   AS u
-                        INNER JOIN  auth_user_quick AS q  USING(user_id)
-                             WHERE  u.user_id = {?} AND u.perms IN('admin', 'user')
-                             LIMIT  1", $user);
+        $res  = XDB::query("SELECT  a.uid, a.display_name, a.full_name,
+                                    a.sex = 'female' AS femme,
+                                    a.email_format, a.token,
+                                    at.perms, a.is_admin
+                              FROM  accounts AS a
+                        INNER JOIN  account_types AS at ON (at.type = a.type)
+                             WHERE  a.uid = {?} AND a.state = 'active'
+                             LIMIT  1", $user->id());
         $sess = $res->fetchOneAssoc();
-        $perms = $sess['perms'];
-        unset($sess['perms']);
         $_SESSION = array_merge($_SESSION, $sess);
-        S::set('perms', User::makePerms($perms));
+        $this->makePerms(S::s('perms'), S::b('is_admin'));
         S::kill('challenge');
         S::kill('loginX');
         S::kill('may_update');