renamed ApiToken to apikey

This commit is contained in:
tracer 2022-09-29 19:25:18 +02:00
parent bc1b9c1204
commit 9dca565296
1 changed files with 21 additions and 13 deletions

View File

@ -16,8 +16,8 @@ class Apikey
public function __construct( public function __construct(
private int $id = 0, private int $id = 0,
private string $name = '', private string $name = '',
private string $apiTokenPrefix = '', private string $apikey = '',
private string $apiToken = '', private string $apikeyPrefix = '',
private readonly string $passphrase = '' private readonly string $passphrase = ''
) )
{ {
@ -27,31 +27,39 @@ class Apikey
$encryptionKey = $configController->getConfig(configKey: 'encryptionKey'); $encryptionKey = $configController->getConfig(configKey: 'encryptionKey');
$this->apiTokenPrefix = strtok(string: $this->passphrase, token: '.'); $this->apikey = strtok(string: $this->passphrase, token: '.');
try { try {
$this->apiToken = $encryptionController->safeEncrypt(message: $this->passphrase, key: $encryptionKey); $this->apikey = $encryptionController->safeEncrypt(message: $this->passphrase, key: $encryptionKey);
} catch (Exception|SodiumException $e) { } catch (Exception|SodiumException $e) {
die($e->getMessage() . PHP_EOL); die($e->getMessage() . PHP_EOL);
} }
} }
} }
/**
* @return string
*/
public function getPassphrase(): string
{
return $this->passphrase;
}
/** /**
* @return String * @return String
*/ */
public function getApiToken(): string public function getApikey(): string
{ {
return $this->apiToken; return $this->apikey;
} }
/** /**
* @return string * @return string
*/ */
public function getApiTokenPrefix(): string public function getApikeyPrefix(): string
{ {
return $this->apiTokenPrefix; return $this->apikeyPrefix;
} }
@ -80,19 +88,19 @@ class Apikey
} }
/** /**
* @param string $apiTokenPrefix * @param string $apikeyPrefix
*/ */
public function setApiTokenPrefix(string $apiTokenPrefix): void public function setApikeyPrefix(string $apikeyPrefix): void
{ {
$this->apiTokenPrefix = $apiTokenPrefix; $this->apikeyPrefix = $apikeyPrefix;
} }
/** /**
* @param String $apiToken * @param String $apiToken
*/ */
public function setApiToken(string $apiToken): void public function setApikey(string $apikey): void
{ {
$this->apiToken = $apiToken; $this->apikey = $apikey;
} }