Skip to content

Commit c8e7df6

Browse files
committed
Better HTTP response in case the login token is invalid.
1 parent 02183df commit c8e7df6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/presenters/LoginPresenter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace App\Presenters;
44

5+
use App\Exceptions\BadRequestException;
56
use App\Exceptions\ForbiddenRequestException;
67
use App\Exceptions\InvalidAccessTokenException;
78
use App\Exceptions\NotFoundException;
9+
use App\Exceptions\RecodexApiException;
810
use App\Exceptions\WrongCredentialsException;
911
use App\Model\Entity\User;
1012
use App\Model\Repository\Users;
@@ -84,7 +86,11 @@ public function actionDefault()
8486
{
8587
$req = $this->getRequest();
8688
$tempToken = $req->getPost("token");
87-
$instanceId = $this->recodexApi->getTempTokenInstance($tempToken);
89+
try {
90+
$instanceId = $this->recodexApi->getTempTokenInstance($tempToken);
91+
} catch (RecodexApiException $e) {
92+
throw new BadRequestException("Invalid token from ReCodEx API", $e);
93+
}
8894

8995
// Call ReCodEx API and get full token + user info using the temporary token
9096
$this->recodexApi->setAuthToken($tempToken);

0 commit comments

Comments
 (0)