Closed M-Shahbaz closed 3 years ago
You could do something similar by returning a 401 response from the after
handler.
use Tuupola\Middleware\JwtAuthentication;
use Tuupola\Http\Factory\ResponseFactory;
$app->add(new JwtAuthentication([
"secret" => "supersecretkeyyoushouldnotcommittogithub",
"path" => ["/protected"],
"after" => function ($response, $arguments) {
if ($authfails) {
return (new ResponseFactory)->createResponse(401);
}
return $response;
}
]));
Ok, thanks
How to use Callback feature from 2.x branch in 3.x branch?
Need authentication force to
fail
.Callback Callback is called only when authentication succeeds. It receives decoded token in arguments. If callback returns boolean
false
authentication is forced to befailed
.You can also use callback for storing the value of decoded token for later use.