Created some routes
This commit is contained in:
parent
736399cf15
commit
7eb8d899bb
|
@ -1,4 +1,9 @@
|
|||
login:
|
||||
path: '/login/'
|
||||
default:
|
||||
path: '/'
|
||||
defaults:
|
||||
_controller: JeroenED\Webcron\Controller\SecurityController::loginAction
|
||||
_controller: JeroenED\Webcron\Controller\DefaultController::defaultAction
|
||||
|
||||
login:
|
||||
path: '/login'
|
||||
defaults:
|
||||
_controller: JeroenED\Webcron\Controller\SecurityController::loginAction
|
|
@ -1,15 +1,19 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace JeroenED\Framework;
|
||||
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use http\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Routing\Loader\YamlFileLoader;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Matcher\UrlMatcher;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
class Kernel
|
||||
{
|
||||
|
@ -90,7 +94,7 @@ class Kernel
|
|||
|
||||
public function getDbCon(): Connection
|
||||
{
|
||||
$db = DriverManager::getConnection(['url' => $_ENV['DATABASE']]);
|
||||
return DriverManager::getConnection(['url' => $_ENV['DATABASE']]);
|
||||
}
|
||||
|
||||
private function createResponse($request, $routes): Response
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use JeroenED\Framework\Kernel;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
require_once '../bootstrap.php';
|
||||
|
||||
$kernel = new Kernel();
|
||||
$kernel->setProjectDir(__DIR__);
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace JeroenED\Webcron\Controller;
|
||||
|
||||
use JeroenED\Framework\Controller;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
public function DefaultAction() {
|
||||
if(!isset($_SESSION['isAuthenticated']) || !$_SESSION['isAuthenticated']) {
|
||||
return new RedirectResponse($this->generateRoute('login'));
|
||||
}
|
||||
return new Response('Not yet implemented', 425);
|
||||
}
|
||||
}
|
|
@ -4,12 +4,16 @@
|
|||
namespace JeroenED\Webcron\Controller;
|
||||
|
||||
use JeroenED\Framework\Controller;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SecurityController extends Controller
|
||||
{
|
||||
public function loginAction(): Response
|
||||
{
|
||||
if(isset($_SESSION['isAuthenticated']) && $_SESSION['isAuthenticated']) {
|
||||
return new RedirectResponse($this->generateRoute('default'));
|
||||
}
|
||||
return $this->render('security/login.html.twig');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue