Skip to content

Instantly share code, notes, and snippets.

@fables-tales
Created July 15, 2010 22:50
Show Gist options
  • Save fables-tales/477651 to your computer and use it in GitHub Desktop.
Save fables-tales/477651 to your computer and use it in GitHub Desktop.
<?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