Hey, i have middleware like this, to authenticate user via JWT, and question is how to modify config array with data stored in $decode variable. Is it possible?
$app->add(
function (Request $request, Response $response, callable $next) use ($config) {
$input = $request->getParams();
if (empty($input['token'])) {
return $response->withStatus(401);
}
try {
$decoded = \Firebase\JWT\JWT::decode($input['token'], $config['jwt_key'], ['HS256']);
} catch (\Exception $e) {
return $response->withStatus(401);
}
return $next($request, $response);
}
);