mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 20:24:44 +02:00
Catch correct Exceptions when updating/ deleting subusers (#828)
This commit is contained in:
parent
663b097d22
commit
026494c353
@ -10,7 +10,6 @@ use Illuminate\Http\Client\RequestException;
|
|||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\Exception\TransferException;
|
|
||||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
|
||||||
class DaemonServerRepository extends DaemonRepository
|
class DaemonServerRepository extends DaemonRepository
|
||||||
@ -97,7 +96,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->getHttpClient()->delete('/api/servers/' . $this->server->uuid);
|
$this->getHttpClient()->delete('/api/servers/' . $this->server->uuid);
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +115,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
'/api/servers/%s/reinstall',
|
'/api/servers/%s/reinstall',
|
||||||
$this->server->uuid
|
$this->server->uuid
|
||||||
));
|
));
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,7 +135,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
'/api/servers/%s/archive',
|
'/api/servers/%s/archive',
|
||||||
$this->server->uuid
|
$this->server->uuid
|
||||||
));
|
));
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +158,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
'/api/servers/%s/transfer',
|
'/api/servers/%s/transfer',
|
||||||
$this->server->uuid
|
$this->server->uuid
|
||||||
));
|
));
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +174,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +209,7 @@ class DaemonServerRepository extends DaemonRepository
|
|||||||
->post(sprintf('/api/servers/%s/ws/deny', $this->server->uuid), [
|
->post(sprintf('/api/servers/%s/ws/deny', $this->server->uuid), [
|
||||||
'jtis' => $jtis,
|
'jtis' => $jtis,
|
||||||
]);
|
]);
|
||||||
} catch (TransferException $exception) {
|
} catch (GuzzleException $exception) {
|
||||||
throw new DaemonConnectionException($exception);
|
throw new DaemonConnectionException($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ use Illuminate\Database\ConnectionInterface;
|
|||||||
use App\Traits\Services\ReturnsUpdatedModels;
|
use App\Traits\Services\ReturnsUpdatedModels;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
use App\Exceptions\Http\Connection\DaemonConnectionException;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
|
||||||
class DetailsModificationService
|
class DetailsModificationService
|
||||||
{
|
{
|
||||||
@ -41,7 +42,7 @@ class DetailsModificationService
|
|||||||
if ($server->owner_id !== $owner) {
|
if ($server->owner_id !== $owner) {
|
||||||
try {
|
try {
|
||||||
$this->serverRepository->setServer($server)->revokeUserJTI($owner);
|
$this->serverRepository->setServer($server)->revokeUserJTI($owner);
|
||||||
} catch (DaemonConnectionException $exception) {
|
} catch (ConnectionException|DaemonConnectionException) {
|
||||||
// Do nothing. A failure here is not ideal, but it is likely to be caused by daemon
|
// Do nothing. A failure here is not ideal, but it is likely to be caused by daemon
|
||||||
// being offline, or in an entirely broken state. Remember, these tokens reset every
|
// being offline, or in an entirely broken state. Remember, these tokens reset every
|
||||||
// few minutes by default, we're just trying to help it along a little quicker.
|
// few minutes by default, we're just trying to help it along a little quicker.
|
||||||
|
@ -8,6 +8,7 @@ use App\Facades\Activity;
|
|||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Subuser;
|
use App\Models\Subuser;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
|
||||||
class SubuserDeletionService
|
class SubuserDeletionService
|
||||||
{
|
{
|
||||||
@ -29,7 +30,7 @@ class SubuserDeletionService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
|
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
|
||||||
} catch (DaemonConnectionException $exception) {
|
} catch (ConnectionException|DaemonConnectionException $exception) {
|
||||||
// Don't block this request if we can't connect to the daemon instance.
|
// Don't block this request if we can't connect to the daemon instance.
|
||||||
logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use App\Facades\Activity;
|
|||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Subuser;
|
use App\Models\Subuser;
|
||||||
use App\Repositories\Daemon\DaemonServerRepository;
|
use App\Repositories\Daemon\DaemonServerRepository;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
|
||||||
class SubuserUpdateService
|
class SubuserUpdateService
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ class SubuserUpdateService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
|
$this->serverRepository->setServer($server)->revokeUserJTI($subuser->user_id);
|
||||||
} catch (DaemonConnectionException $exception) {
|
} catch (ConnectionException|DaemonConnectionException $exception) {
|
||||||
// Don't block this request if we can't connect to the daemon instance. Chances are it is
|
// Don't block this request if we can't connect to the daemon instance. Chances are it is
|
||||||
// offline and the token will be invalid once daemon boots back.
|
// offline and the token will be invalid once daemon boots back.
|
||||||
logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
logger()->warning($exception, ['user_id' => $subuser->user_id, 'server_id' => $server->id]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user