2023-12-03 22:10:18 +04:00
|
|
|
<?php
|
|
|
|
namespace nur\b\authnz;
|
|
|
|
|
2024-06-13 10:55:26 +04:00
|
|
|
use ArrayAccess;
|
2023-12-03 22:10:18 +04:00
|
|
|
use nur\A;
|
2024-06-13 10:55:26 +04:00
|
|
|
use nur\b\coll\TBaseArray;
|
|
|
|
use nur\b\coll\TGenericArray;
|
|
|
|
|
|
|
|
class InvalidUser implements IAuthzUser, ArrayAccess {
|
|
|
|
use TBaseArray, TGenericArray;
|
2023-12-03 22:10:18 +04:00
|
|
|
|
|
|
|
/** @var self */
|
|
|
|
private static $instance;
|
|
|
|
|
|
|
|
static final function with(?string $username=null): self {
|
|
|
|
if ($username !== null) return new self($username);
|
|
|
|
if (self::$instance === null) self::$instance = new self();
|
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
function __construct(?string $username=null) {
|
|
|
|
$this->username = $username;
|
2024-06-13 10:55:26 +04:00
|
|
|
$this->data = [];
|
2023-12-03 22:10:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function isValid(): bool {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private $username;
|
|
|
|
|
|
|
|
function getUsername(): string {
|
|
|
|
$username = $this->username;
|
|
|
|
return $username !== null? $username: "INVALID";
|
|
|
|
}
|
|
|
|
|
|
|
|
function validatePassword(string $password): bool {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDisplayName(): ?string {
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getShortName(): ?string {
|
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMail(): ?string {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRole(): ?string {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function isRole($roles): bool {
|
|
|
|
return $roles === null || in_array(self::ROLE_ANON, A::with($roles));
|
|
|
|
}
|
|
|
|
|
|
|
|
function isPerm($perm): bool {
|
|
|
|
return $perm === null;
|
|
|
|
}
|
|
|
|
|
|
|
|
function has($key): bool {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|