docker: gd extension + 2FA Bugfix
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Core\Objects\DatabaseEntity;
|
||||
|
||||
use Core\API\Parameter\Parameter;
|
||||
use Core\Driver\SQL\SQL;
|
||||
use Core\Objects\DatabaseEntity\Attribute\DefaultValue;
|
||||
use Core\Objects\DatabaseEntity\Attribute\ExtendingEnum;
|
||||
use Core\Objects\DatabaseEntity\Attribute\MaxLength;
|
||||
@@ -16,11 +17,16 @@ use Core\Objects\Router\StaticFileRoute;
|
||||
abstract class Route extends DatabaseEntity {
|
||||
|
||||
const PARAMETER_PATTERN = "/^{([^:]+)(:(.*?)(\?)?)?}$/";
|
||||
|
||||
const TYPE_DYNAMIC = "dynamic";
|
||||
const TYPE_STATIC = "static";
|
||||
const TYPE_REDIRECT_PERMANENTLY = "redirect_permanently";
|
||||
const TYPE_REDIRECT_TEMPORARY = "redirect_temporary";
|
||||
const ROUTE_TYPES = [
|
||||
"redirect_temporary" => RedirectRoute::class,
|
||||
"redirect_permanently" => RedirectRoute::class,
|
||||
"static" => StaticFileRoute::class,
|
||||
"dynamic" => DocumentRoute::class
|
||||
self::TYPE_REDIRECT_TEMPORARY => RedirectRoute::class,
|
||||
self::TYPE_REDIRECT_PERMANENTLY => RedirectRoute::class,
|
||||
self::TYPE_STATIC => StaticFileRoute::class,
|
||||
self::TYPE_DYNAMIC => DocumentRoute::class
|
||||
];
|
||||
|
||||
#[MaxLength(128)]
|
||||
@@ -77,6 +83,13 @@ abstract class Route extends DatabaseEntity {
|
||||
|
||||
public abstract function call(Router $router, array $params): string;
|
||||
|
||||
protected function readExtra() { }
|
||||
|
||||
public function postFetch(SQL $sql, array $row) {
|
||||
parent::postFetch($sql, $row);
|
||||
$this->readExtra();
|
||||
}
|
||||
|
||||
protected function getArgs(): array {
|
||||
return [$this->pattern, $this->exact];
|
||||
}
|
||||
@@ -204,4 +217,28 @@ abstract class Route extends DatabaseEntity {
|
||||
"active" => $this->active,
|
||||
];
|
||||
}
|
||||
|
||||
public function setActive(bool $active) {
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
public function getType(): string {
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setPattern(string $pattern) {
|
||||
$this->pattern = $pattern;
|
||||
}
|
||||
|
||||
public function setExtra(string $extra) {
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
||||
public function setTarget(string $target) {
|
||||
$this->target = $target;
|
||||
}
|
||||
|
||||
public function setExact(bool $exact) {
|
||||
$this->exact = $exact;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ abstract class TwoFactorToken extends DatabaseEntity {
|
||||
#[ExtendingEnum(self::TWO_FACTOR_TOKEN_TYPES)] private string $type;
|
||||
private bool $confirmed;
|
||||
private bool $authenticated;
|
||||
#[MaxLength(512)] private string $data;
|
||||
#[MaxLength(512)] private ?string $data;
|
||||
|
||||
public function __construct(string $type, ?int $id = null, bool $confirmed = false) {
|
||||
parent::__construct($id);
|
||||
@@ -27,6 +27,7 @@ abstract class TwoFactorToken extends DatabaseEntity {
|
||||
$this->type = $type;
|
||||
$this->confirmed = $confirmed;
|
||||
$this->authenticated = $_SESSION["2faAuthenticated"] ?? false;
|
||||
$this->data = null;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array {
|
||||
@@ -63,11 +64,12 @@ abstract class TwoFactorToken extends DatabaseEntity {
|
||||
return $this->confirmed;
|
||||
}
|
||||
|
||||
public function getId(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function isAuthenticated(): bool {
|
||||
return $this->authenticated;
|
||||
}
|
||||
|
||||
public function confirm(SQL $sql): bool {
|
||||
$this->confirmed = true;
|
||||
return $this->save($sql) !== false;
|
||||
}
|
||||
}
|
||||
@@ -93,4 +93,8 @@ class User extends DatabaseEntity {
|
||||
$this->lastOnline = new \DateTime();
|
||||
return $this->save($sql, ["last_online", "language_id"]);
|
||||
}
|
||||
|
||||
public function setTwoFactorToken(TwoFactorToken $twoFactorToken) {
|
||||
$this->twoFactorToken = $twoFactorToken;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user