mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 10:40:40 -04:00
Merge 3b353ede60 into d02155784b
This commit is contained in:
commit
7dfbfdd6e5
2 changed files with 28 additions and 18 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue