I started a project with slim3 framework. In my project I wrote a route group called admin
for administrators.
$app->group('/admin', function () use ($app) {
$app->add( new AdminMiddleWare() );
$app->get('/books/{id}', function ($request, $response, $args) {
...
});
});
any of administrators should send a GET token for validation . I want to create a middleware for checking admins tokens and if the token not set or is invalid display 403 error.
the Middleware class :
class AdminMiddleWare
{
/**
* Example middleware invokable class
*
* @param \Psr\Http\Message\ServerRequestInterface $request PSR7 request
* @param \Psr\Http\Message\ResponseInterface $response PSR7 response
* @param callable $next Next middleware
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function __invoke($request, $response, $next)
{
???
}
}
can you help me?