58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Slovocast;
|
|
|
|
use Slim\App;
|
|
use Slovocast\Controller\HomePage;
|
|
use Slovocast\Controller\HealthCheck;
|
|
use Slovocast\Controller\DashboardPage;
|
|
use Slovocast\Controller\User\RegisterUserPage;
|
|
use Slovocast\Controller\User\RegisterUserAction;
|
|
use Slovocast\Controller\User\LoginUserPage;
|
|
use Slovocast\Controller\User\LoginUserAction;
|
|
use Slovocast\Middleware\VerifyPasswordMiddleware;
|
|
use Slovocast\Middleware\AuthenticatedMiddleware;
|
|
|
|
class Routes
|
|
{
|
|
/**
|
|
* @param App $app Instantiated Application
|
|
* @return void
|
|
*/
|
|
public static function setup(App $app): void
|
|
{
|
|
$app->get('/', HomePage::class);
|
|
$app->get('/healthcheck', HealthCheck::class);
|
|
// User Routes
|
|
self::users($app);
|
|
self::dashboard($app);
|
|
}
|
|
|
|
/**
|
|
* @param App $app Instantiated Application
|
|
*/
|
|
protected static function users(App $app): void
|
|
{
|
|
$app->get('/users/register', RegisterUserPage::class)
|
|
->setName('user-register-page');
|
|
$app->post('/users/register', RegisterUserAction::class)
|
|
->add(VerifyPasswordMiddleware::class)
|
|
->setName('user-register-action');
|
|
|
|
$app->get('/login', LoginUserPage::class)
|
|
->setName('user-login-page');
|
|
$app->post('/login', LoginUserAction::class)
|
|
->setName('user-login-action');
|
|
}
|
|
|
|
/**
|
|
* @param App $app Instance of the application
|
|
*/
|
|
protected static function dashboard(App $app): void
|
|
{
|
|
$app->get('/dashboard', DashboardPage::class)
|
|
->add(AuthenticatedMiddleware::class)
|
|
->setName('user-dashboard');
|
|
}
|
|
}
|