Final adjustments to Daemon <-> Panel communication change
This commit is contained in:
parent
8e2b77dc1e
commit
7d1c233c49
32 changed files with 528 additions and 538 deletions
|
@ -25,21 +25,19 @@
|
|||
namespace Pterodactyl\Services\DaemonKeys;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Pterodactyl\Models\DaemonKey;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Contracts\Repository\DaemonKeyRepositoryInterface;
|
||||
|
||||
class DaemonKeyUpdateService
|
||||
{
|
||||
const INTERNAL_TOKEN_IDENTIFIER = 'i_';
|
||||
|
||||
/**
|
||||
* @var \Carbon\Carbon
|
||||
*/
|
||||
protected $carbon;
|
||||
|
||||
/**
|
||||
* @var
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
@ -68,7 +66,7 @@ class DaemonKeyUpdateService
|
|||
/**
|
||||
* Update a daemon key to expire the previous one.
|
||||
*
|
||||
* @param \Pterodactyl\Models\DaemonKey|int $key
|
||||
* @param int $key
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
|
@ -77,15 +75,12 @@ class DaemonKeyUpdateService
|
|||
*/
|
||||
public function handle($key)
|
||||
{
|
||||
if ($key instanceof DaemonKey) {
|
||||
$key = $key->id;
|
||||
}
|
||||
|
||||
$secret = self::INTERNAL_TOKEN_IDENTIFIER . str_random(40);
|
||||
Assert::integerish($key, 'First argument passed to handle must be an integer, received %s.');
|
||||
|
||||
$secret = DaemonKeyRepositoryInterface::INTERNAL_KEY_IDENTIFIER . str_random(40);
|
||||
$this->repository->withoutFresh()->update($key, [
|
||||
'secret' => $secret,
|
||||
'expires_at' => $this->carbon->now()->addMinutes($this->config->get('pterodactyl.api.key_expire_time')),
|
||||
'expires_at' => $this->carbon->now()->addMinutes($this->config->get('pterodactyl.api.key_expire_time'))->toDateTimeString(),
|
||||
]);
|
||||
|
||||
return $secret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue