Merge branch 'develop' into feature/vuejs

This commit is contained in:
Dane Everitt 2018-12-16 14:20:35 -08:00
commit 21ffa08d66
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
54 changed files with 407 additions and 243 deletions

View file

@ -50,24 +50,41 @@ class NodeUpdateService
*
* @param \Pterodactyl\Models\Node $node
* @param array $data
* @param bool $resetToken
*
* @return \Pterodactyl\Models\Node
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
* @throws \Pterodactyl\Exceptions\Service\Node\ConfigurationNotPersistedException
*/
public function handle(Node $node, array $data)
public function handle(Node $node, array $data, bool $resetToken = false)
{
if (! is_null(array_get($data, 'reset_secret'))) {
if ($resetToken) {
$data['daemonSecret'] = str_random(Node::DAEMON_SECRET_LENGTH);
unset($data['reset_secret']);
}
$this->connection->beginTransaction();
/** @var \Pterodactyl\Models\Node $updatedModel */
$updatedModel = $this->repository->update($node->id, $data);
try {
$this->configRepository->setNode($updatedModel)->update();
if ($resetToken) {
// We need to clone the new model and set it's authentication token to be the
// old one so we can connect. Then we will pass the new token through as an
// override on the call.
$cloned = $updatedModel->replicate(['daemonSecret']);
$cloned->setAttribute('daemonSecret', $node->getAttribute('daemonSecret'));
$this->configRepository->setNode($cloned)->update([
'keys' => [$data['daemonSecret']],
]);
} else {
$this->configRepository->setNode($updatedModel)->update();
}
$this->connection->commit();
} catch (RequestException $exception) {
// Failed to connect to the Daemon. Let's go ahead and save the configuration

View file

@ -102,6 +102,7 @@ class AuthenticateUsingPasswordService
return [
'server' => $server->uuid,
'token' => $this->keyProviderService->handle($server, $user),
'permissions' => $permissions ?? ['*'],
];
}
}