You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
908 B

<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class Controller {
private function _is_logged_in(&$request, &$response) {
session_start();
if(!array_key_exists('user_id', $_SESSION)) {
session_destroy();
$response->setStatusCode(302);
$response->headers->set('Location', '/login?return_to='.$request->getPathInfo());
return false;
} else {
return true;
}
}
public function index(Request $request, Response $response) {
$response->setContent(view('index', [
'title' => 'Telegraph'
]));
return $response;
}
public function dashboard(Request $request, Response $response) {
if(!$this->_is_logged_in($request, $response)) {
return $response;
}
$response->setContent(view('dashboard', [
'title' => 'Telegraph Dashboard'
]));
return $response;
}
}