You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 19, 2022. It is now read-only.
I really enjoy using slimcontroller. Is it possible to include an authentication middleware while defining routes in index.php ?
e.g. I have $authenticate defined:
$authenticate = function ($app) {
return function () use ($app) {
if (!isset($_SESSION['user'])) {
$_SESSION['urlRedirect'] = $app->request()->getPathInfo();
$app->flash('error', 'Login required');
$app->redirect('/login');
}
};
};
When adding routes:
$app->addRoutes(array(
'/' => 'HomeController:login')
);
Do something like:
$app->addRoutes(array(
'/' => array('HomeController:login', $authenticate))
);
Thank you.