Auth extension

From: Date: Mon, 22 Oct 2001 20:26:54 +0000
Subject: Auth extension
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-2359@lists.php.net to get a copy of this message
Hi! I made a small extension to the Auth class to make it optional if the user has to authenticate or not. This makes it possible to generate pages where authenticated users get other informations than "nobodies". It's similar to the default_auth class of PHPLib. Shall I make a new class (eg. AuthDefault) or patch the existing one? Guido -- Guido Schoepp, gusmail@gmx.net class Auth2 extends Auth { var $authrequired; function Auth2($storage_driver = "DB", $storage_options = "", $authrequired = true) { parent::Auth($storage_driver, $storage_options); $this->authrequired = $authrequired; } function login() { /** * When the user has already entered a username, * we have to validate it. */ if ($this->username != "") { $login_ok = $this->storage->fetchData($this->username,$this->password); } /** * If the login failed, output the login screen again */ if ((!$login_ok || $this->username == "") && ($this->authrequired)) { $this->drawLogin(); exit; } } function getUsername() { $res = parent::getUsername(); if ($res == "" && !$this->authrequired) return "nobody"; return $res; } function sessionValidThru() { return ($GLOBALS['HTTP_SESSION_VARS']['auth']['idle'] + $this->idle); } }

« previous php.pear.dev (#2359) next »