Skip to content

Commit

Permalink
Disable token if is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Tamás András Horváth <[email protected]>
  • Loading branch information
icetee committed May 11, 2023
1 parent 56e5ac2 commit 94329a6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/App/src/Middleware/StatisticsAccountMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

use function strlen;

class StatisticsAccountMiddleware implements MiddlewareInterface
{
public function __construct(
Expand All @@ -26,7 +28,10 @@ public function process(
): ResponseInterface {
$authCode = $request->getHeaderLine('Authorization');

if ($authCode !== $this->config['app']['stat']['token']) {
if (
$authCode !== $this->config['app']['stat']['token'] ||
strlen($authCode) === 0
) {
return new JsonResponse([
'message' => 'No authentication',
], 401);
Expand Down

0 comments on commit 94329a6

Please sign in to comment.