Defined custom NotFoundMiddleware for rest routes

This commit is contained in:
Alejandro Celaya
2016-07-26 19:09:54 +02:00
parent 83f29080c6
commit a81dba58bd
7 changed files with 88 additions and 18 deletions

View File

@@ -69,7 +69,9 @@ class CheckAuthenticationMiddleware implements MiddlewareInterface
// If current route is the authenticate route or an OPTIONS request, continue to the next middleware
/** @var RouteResult $routeResult */
$routeResult = $request->getAttribute(RouteResult::class);
if ((isset($routeResult) && $routeResult->getMatchedRouteName() === 'rest-authenticate')
if (! isset($routeResult)
|| $routeResult->isFailure()
|| $routeResult->getMatchedRouteName() === 'rest-authenticate'
|| $request->getMethod() === 'OPTIONS'
) {
return $out($request, $response);