UserToken / UserAPI

This commit is contained in:
2022-11-19 01:15:34 +01:00
parent f6bae08c05
commit b5b8f9b856
21 changed files with 496 additions and 613 deletions

View File

@@ -3,6 +3,7 @@
namespace Core\Objects\DatabaseEntity;
use Core\Driver\SQL\Expression\CurrentTimeStamp;
use Core\Driver\SQL\SQL;
use Core\Objects\DatabaseEntity\Attribute\MaxLength;
use Core\Objects\DatabaseEntity\Attribute\DefaultValue;
@@ -16,12 +17,13 @@ class GpgKey extends DatabaseEntity {
private \DateTime $expires;
#[DefaultValue(CurrentTimeStamp::class)] private \DateTime $added;
public function __construct(int $id, bool $confirmed, string $fingerprint, string $algorithm, string $expires) {
parent::__construct($id);
$this->confirmed = $confirmed;
public function __construct(string $fingerprint, string $algorithm, \DateTime $expires) {
parent::__construct();
$this->confirmed = false;
$this->fingerprint = $fingerprint;
$this->algorithm = $algorithm;
$this->expires = new \DateTime($expires);
$this->expires = $expires;
$this->added = new \DateTime();
}
public static function encrypt(string $body, string $gpgFingerprint): array {
@@ -130,4 +132,9 @@ class GpgKey extends DatabaseEntity {
"confirmed" => $this->confirmed
];
}
public function confirm(SQL $sql): bool {
$this->confirmed = true;
return $this->save($sql);
}
}