Skip to content

Commit

Permalink
Add route for OPTIONS requests to the Auth Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Oct 2, 2019
1 parent 0c3eda9 commit 6fcda9a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Classes/Handler/AuthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cundd\Rest\Authentication\UserProviderInterface;
use Cundd\Rest\Http\RestRequestInterface;
use Cundd\Rest\RequestFactoryInterface;
use Cundd\Rest\Router\Route;
use Cundd\Rest\Router\RouterInterface;
use Cundd\Rest\SessionManager;

Expand Down Expand Up @@ -141,6 +142,15 @@ public function logout()
];
}

/**
* @return bool
*/
public function options()
{
// TODO: Respond with the correct preflight headers
return true;
}

/**
* Let the handler configure the routes
*
Expand All @@ -149,9 +159,12 @@ public function logout()
*/
public function configureRoutes(RouterInterface $router, RestRequestInterface $request)
{
$router->routeGet($request->getResourceType() . '/login/?', [$this, 'getStatus']);
$router->routePost($request->getResourceType() . '/login/?', [$this, 'checkLogin']);
$router->routeGet($request->getResourceType() . '/logout/?', [$this, 'logout']);
$router->routePost($request->getResourceType() . '/logout/?', [$this, 'logout']);
$resourceType = $request->getResourceType();
$router->routeGet($resourceType . '/login/?', [$this, 'getStatus']);
$router->routePost($resourceType . '/login/?', [$this, 'checkLogin']);
$router->add(Route::options($resourceType . '/login/?', [$this, 'options']));
$router->routeGet($resourceType . '/logout/?', [$this, 'logout']);
$router->routePost($resourceType . '/logout/?', [$this, 'logout']);
$router->add(Route::options($resourceType . '/logout/?', [$this, 'options']));
}
}

0 comments on commit 6fcda9a

Please sign in to comment.