Created
July 15, 2010 22:50
-
-
Save fables-tales/477651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once("auth.php"); | |
class NoCredentialsAuthBackend extends AuthBackend | |
{ | |
public static function getInstance() | |
{ | |
if (self::$instance == null) | |
{ | |
self::$instance = new NoCredentialsAuthBackend(); | |
} | |
return self::$instance; | |
} | |
private function __construct() | |
{ | |
$this->authed = false; | |
$config = Configuration::getInstance(); | |
$this->user = $config->getConfig("user.default"); | |
} | |
public function getCurrentUser() | |
{ | |
if ($this->authed) | |
{ | |
return null; | |
} | |
else | |
{ | |
return $this->user; | |
} | |
} | |
public function authUser($authtoken) | |
{ | |
if (isset($authtoken["user"]) && isset($authtoken["password"])) | |
{ | |
$this->authed = true; | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} | |
public function getNextAuthToken() | |
{ | |
return 1; | |
} | |
public function deauthUser($authtoken) | |
{ | |
if ($authtoken != 1) | |
{ | |
throw new Exception("invalid deauth token", 0x34); | |
} | |
$this->authed = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment