This commit is contained in:
Josh 2026-06-13 05:27:24 +02:00 committed by GitHub
commit 7dfbfdd6e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 18 deletions

View file

@ -45,18 +45,20 @@ class WipeController extends Controller {
#[NoCSRFRequired]
#[AnonRateLimit(limit: 10, period: 300)]
#[FrontpageRoute(verb: 'POST', url: '/core/wipe/check')]
public function checkWipe(string $token): JSONResponse {
try {
if ($this->remoteWipe->start($token)) {
return new JSONResponse([
'wipe' => true
]);
public function checkWipe(?string $token = ''): JSONResponse {
if (!empty($token)) {
try {
if ($this->remoteWipe->start($token)) {
return new JSONResponse([
'wipe' => true
]);
}
} catch (InvalidTokenException $e) {
// do nothing special, handled below
}
return new JSONResponse([], Http::STATUS_NOT_FOUND);
} catch (InvalidTokenException $e) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
/**
@ -73,15 +75,17 @@ class WipeController extends Controller {
#[NoCSRFRequired]
#[AnonRateLimit(limit: 10, period: 300)]
#[FrontpageRoute(verb: 'POST', url: '/core/wipe/success')]
public function wipeDone(string $token): JSONResponse {
try {
if ($this->remoteWipe->finish($token)) {
return new JSONResponse([]);
public function wipeDone(?string $token = ''): JSONResponse {
if (!empty($token)) {
try {
if ($this->remoteWipe->finish($token)) {
return new JSONResponse([]);
}
} catch (InvalidTokenException $e) {
// do nothing special, handled below
}
return new JSONResponse([], Http::STATUS_NOT_FOUND);
} catch (InvalidTokenException $e) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
}

View file

@ -55,6 +55,12 @@ class WipeControllerTest extends TestCase {
$this->remoteWipe->method('start')
->with('mytoken')
->willThrowException(new InvalidTokenException());
$this->remoteWipe->method('start')
->with('')
->willThrowException(new InvalidTokenException());
$this->remoteWipe->method('start')
->with(NULL)
->willThrowException(new InvalidTokenException());
} else {
$this->remoteWipe->method('start')
->with('mytoken')