diff --git a/Documentation/data.puml b/Documentation/data.puml index 0ad5135..7e6e777 100755 --- a/Documentation/data.puml +++ b/Documentation/data.puml @@ -68,4 +68,24 @@ class Color { + getValue(): int } +class AuthController{ + + + login (requete) : int + + register (requete) : int +} +AuthController --> "- modelAuth" AuthModel + +class AuthModel{ + + login (mail : string, password : string) + + register (mail : string, password :string) +} +AuthModel --> "- gateway" AuthGateway + +class AuthGateway{ + + + insert(mail : string, password : string) + + isAccountEqual(mail : string, password : string) +} + + @enduml \ No newline at end of file diff --git a/public/index.php b/public/index.php index 4c5290b..74124e7 100644 --- a/public/index.php +++ b/public/index.php @@ -35,10 +35,13 @@ $router = new AltoRouter(); $router->setBasePath($basePath); $sampleFormController = new SampleFormController(new FormResultGateway($con), $twig); +$authController = new \App\Controller\AuthController(new \App\Gateway\AuthGateway(), $twig); + $router->map("GET", "/", fn() => $sampleFormController->displayForm()); $router->map("POST", "/submit", fn() => $sampleFormController->submitForm($_POST)); $router->map("GET", "/twig", fn() => $sampleFormController->displayFormTwig()); $router->map("POST", "/submit-twig", fn() => $sampleFormController->submitFormTwig($_POST)); +$router->map("GET", "/register", fn() => $authController->displayRegister()); $match = $router->match(); diff --git a/sql/setup-tables.sql b/sql/setup-tables.sql index 0c6fbe7..4f6e0d4 100644 --- a/sql/setup-tables.sql +++ b/sql/setup-tables.sql @@ -1,8 +1,10 @@ -- drop tables here DROP TABLE IF EXISTS FormEntries; +DROP TABLE IF EXISTS AccountUser; CREATE TABLE FormEntries(name varchar, description varchar); +CREATE TABLE AccountUser(name varchar, profilPicture varchar, age int); diff --git a/src/Controller/AuthController.php b/src/Controller/AuthController.php index 3f952c9..f584810 100644 --- a/src/Controller/AuthController.php +++ b/src/Controller/AuthController.php @@ -2,16 +2,27 @@ namespace App\Controller; -use App\Gateway\AccountGateway; +use App\Gateway\AuthGateway; +use App\Model\AuthModel; use Twig\Environment; -class AccountController +class AuthController { - private AccountGateway $gateway; - private Environment $twing; + private AuthModel $model; + private Environment $twig; - public function display(){ - require "src/Views/display_login.html.twig"; + /** + * @param AuthModel $model + * @param Environment $twig + */ + public function __construct(AuthModel $model, Environment $twig) + { + $this->model = $model; + $this->twig = $twig; + } + + public function displayRegister(){ + echo $this->twig->render("display_register.html.twig",[]); } diff --git a/src/Gateway/AuthGateway.php b/src/Gateway/AuthGateway.php index 865faa9..a3f1765 100644 --- a/src/Gateway/AuthGateway.php +++ b/src/Gateway/AuthGateway.php @@ -2,7 +2,7 @@ namespace App\Gateway; -class AccountGateway +class AuthGateway { } \ No newline at end of file diff --git a/src/Model/AuthModel.php b/src/Model/AuthModel.php index 3c94e50..035893b 100644 --- a/src/Model/AuthModel.php +++ b/src/Model/AuthModel.php @@ -2,7 +2,10 @@ namespace App\Model; +use App\Controller\AuthController; + class AuthModel { + private AuthController $controller; } \ No newline at end of file diff --git a/src/Views/display_register.html.twig b/src/Views/display_register.html.twig index 08e6e9f..0e643cb 100644 --- a/src/Views/display_register.html.twig +++ b/src/Views/display_register.html.twig @@ -2,7 +2,7 @@
-