diff --git a/app/Config/Filters.php b/app/Config/Filters.php index eb46a1d..59522ee 100644 --- a/app/Config/Filters.php +++ b/app/Config/Filters.php @@ -34,6 +34,7 @@ class Filters extends BaseFilters 'forcehttps' => ForceHTTPS::class, 'pagecache' => PageCache::class, 'performance' => PerformanceMetrics::class, + 'userSession' => \App\Filters\CheckUserSession::class, ]; /** diff --git a/app/Config/Routes.php b/app/Config/Routes.php index f3d5241..7096152 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -11,4 +11,15 @@ $routes->get('user/(:any)', 'Users::user/$1'); $routes->get('car/(:any)', 'Cars::index/$1'); $routes->get('track/(:any)', 'Tracks::index/$1'); $routes->get('race/(:num)', 'Races::index/$1'); -$routes->get('users', 'Users::index'); \ No newline at end of file +$routes->get('users', 'Users::index'); +$routes->get('login', 'Users::login'); +$routes->post('webserver', 'Webserver::index'); + +$routes->group('dashboard', static function ($routes) { + $routes->get('/', 'Dashboard::index', ['filter' => 'userSession']); + $routes->get('user', 'Dashboard::user', ['filter' => 'userSession']); + $routes->get('logout', 'Dashboard::logout'); + $routes->post('login', 'Dashboard::login'); + $routes->post('update_user', 'Dashboard::updateUser', ['filter' => 'userSession']); + $routes->post('change_passwd', 'Dashboard::changePasswd', ['filter' => 'userSession']); +}); \ No newline at end of file diff --git a/app/Filters/CheckUserSession.php b/app/Filters/CheckUserSession.php new file mode 100644 index 0000000..24e36e2 --- /dev/null +++ b/app/Filters/CheckUserSession.php @@ -0,0 +1,35 @@ +has('userid')) + { + $session->destroy(); + $response = service('response'); + $response->setHeader('Location', base_url('login')); + $response->setStatusCode(302); + + return $response->send(); + } + } + + public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) + { + // Do something here + } +} \ No newline at end of file