X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplsession.php;h=7a243be44ebb552b153cc45a8c9013e46907fdc3;hb=88541046480799a8d92eba186f22e22c0c64efb0;hp=f576f65e38bf42a17230e8d5274c21774b64a034;hpb=8bdb07ee8944d8ef3d37b733477834a64a897aa6;p=platal.git diff --git a/classes/plsession.php b/classes/plsession.php index f576f65..7a243be 100644 --- a/classes/plsession.php +++ b/classes/plsession.php @@ -1,6 +1,6 @@ checkAuth($level)) { return true; } @@ -170,25 +170,36 @@ abstract class PlSession */ abstract public function tokenAuth($login, $token); + /** Set the permissions to the given flagset. + * + * This function sets S::set('perms') with a flagset represeting the combination of + * $perms and $is_admin. + * + * $perms is an abstract object representing the permissions. + * $is_admin is a boolean, true if the current user has site-administration rights. + */ + abstract protected function makePerms($perms, $is_admin); /*** SUID management ***/ /** Start a new SUID session. */ - public function startSUID($user) + public function startSUID($user, $perms = null) { - if (S::has('suid')) { + if (S::suid()) { return false; } - $backup = $_SESSION; - $_SESSION = array(); + $backup = S::changeSession(array()); $this->fillSession(); S::set('suid', $backup); - if (!$this->startSessionAs($user, -1)) { + if (!$this->startSessionAs($user, AUTH_SUID)) { $this->stopSUID(); return false; } S::set('user', $user); + if (!is_null($perms)) { + $this->makePerms($perms, false); + } return true; } @@ -196,16 +207,20 @@ abstract class PlSession */ public function stopSUID() { - if (!S::has('suid')) { + if (!S::suid()) { return false; } - $_SESSION = $_SESSION['suid']; + S::changeSession(S::v('suid')); return true; } /*** Thresholds ***/ + /** Minimum level of authentication that is considered as logged. + */ + abstract public function loggedLevel(); + /** Minimum level of authentication that is considered as sure. */ abstract public function sureLevel();