diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b764555..487aa5c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,13 @@ - - + + + - - + + diff --git a/cache/2b/2b8002d11829b35f2fea035ddfbce126.php b/cache/2b/2b8002d11829b35f2fea035ddfbce126.php new file mode 100644 index 0000000..e318493 --- /dev/null +++ b/cache/2b/2b8002d11829b35f2fea035ddfbce126.php @@ -0,0 +1,127 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ S'inscrazeazeazeire ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ +
+ +
+

Confirmer mot de passe *

+ +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin2.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin2.html.twig"); + } +} diff --git a/cache/6d/6de321060ef2387bc16f534fbbd8a0cb.php b/cache/6d/6de321060ef2387bc16f534fbbd8a0cb.php new file mode 100644 index 0000000..6bacc22 --- /dev/null +++ b/cache/6d/6de321060ef2387bc16f534fbbd8a0cb.php @@ -0,0 +1,144 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ "; + // line 28 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield " ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin4.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 97 => 48, 89 => 43, 71 => 28, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin4.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin4.html.twig"); + } +} diff --git a/cache/b9/b9f06cf0c28af20c02697ea9f4c33b34.php b/cache/b9/b9f06cf0c28af20c02697ea9f4c33b34.php new file mode 100644 index 0000000..9674c2a --- /dev/null +++ b/cache/b9/b9f06cf0c28af20c02697ea9f4c33b34.php @@ -0,0 +1,144 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ "; + // line 28 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["test"] ?? null), "html", null, true); + yield " ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin5.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 97 => 48, 89 => 43, 71 => 28, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin5.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin5.html.twig"); + } +} diff --git a/cache/bb/bb0d1fc28ee0b67e6ef4c12688a04e9a.php b/cache/bb/bb0d1fc28ee0b67e6ef4c12688a04e9a.php new file mode 100644 index 0000000..c19e758 --- /dev/null +++ b/cache/bb/bb0d1fc28ee0b67e6ef4c12688a04e9a.php @@ -0,0 +1,144 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ "; + // line 28 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["test"] ?? null), "html", null, true); + yield " ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin6.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 97 => 48, 89 => 43, 71 => 28, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin6.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin6.html.twig"); + } +} diff --git a/cache/c8/c8a54737c049d7059e9d4f0d28a162e3.php b/cache/c8/c8a54737c049d7059e9d4f0d28a162e3.php new file mode 100644 index 0000000..fc19c20 --- /dev/null +++ b/cache/c8/c8a54737c049d7059e9d4f0d28a162e3.php @@ -0,0 +1,144 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ "; + // line 28 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["test"] ?? null), "html", null, true); + yield " ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin7.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 97 => 48, 89 => 43, 71 => 28, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin7.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin7.html.twig"); + } +} diff --git a/cache/cb/cb360548e4152dd6e9238cff38b4a902.php b/cache/cb/cb360548e4152dd6e9238cff38b4a902.php new file mode 100644 index 0000000..90de806 --- /dev/null +++ b/cache/cb/cb360548e4152dd6e9238cff38b4a902.php @@ -0,0 +1,144 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ "; + // line 28 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["test"] ?? null), "html", null, true); + yield " ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin1.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 97 => 48, 89 => 43, 71 => 28, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin1.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin1.html.twig"); + } +} diff --git a/cache/f2/f21f963662b38a0c5b3c81b499f82bfb.php b/cache/f2/f21f963662b38a0c5b3c81b499f82bfb.php new file mode 100644 index 0000000..a8b3a12 --- /dev/null +++ b/cache/f2/f21f963662b38a0c5b3c81b499f82bfb.php @@ -0,0 +1,141 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield " + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ lo ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\"/> +
+ +
+

Confirmer mot de passe *

+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["errors"] ?? null), "html", null, true); + yield "\" required/> +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin3.html.twig"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 94 => 48, 86 => 43, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin3.html.twig", "/Users/kiem/Documents/WikiFantasy/WF-Website/vue/templates/signin3.html.twig"); + } +} diff --git a/index.php b/index.php index bebf483..977669e 100644 --- a/index.php +++ b/index.php @@ -16,7 +16,7 @@ $co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbwikifantasy;', 'kie //twig $loader = new \Twig\Loader\FilesystemLoader('vue/templates'); $twig = new \Twig\Environment($loader, [ - 'cache' => 'cache', + 'cache' => false, ]); diff --git a/src/Controleur/FrontControler.php b/src/Controleur/FrontControler.php index de9831c..3445bbd 100644 --- a/src/Controleur/FrontControler.php +++ b/src/Controleur/FrontControler.php @@ -16,7 +16,7 @@ Class FrontControler{ $this->co=$co; - $this->listAction = ['visitor' => array('accueil','search','quote','login','signin','quiz'), + $this->listAction = ['visitor' => array('accueil','search','quote','login','signin','quiz','valid'), 'user' => array('quiz','commentary','favorite','logout'), 'admin' => array('null')]; @@ -38,6 +38,7 @@ Class FrontControler{ $router->map('GET|POST', '/quote/[i:idQuote]?', 'VisitorControler'); $router->map('GET|POST', '/login', 'VisitorControler'); $router->map('GET|POST', '/signin', 'VisitorControler'); + $router->map('GET|POST', '/valid', 'VisitorControler'); $router->map('GET|POST', '/quiz/[i:id]?', 'QuizController'); $match = $router->match(); @@ -63,12 +64,11 @@ Class FrontControler{ $this->vueErreur($dVueEreur); } - if(!$this->verifDroit($action)){ + if(!$this->verifDroit($action) ){ $action='login'; $controller='VisitorControler'; } - $controller = '\\Controleur\\' . $controller; $controller = new $controller($this->co, $action); if (is_callable(array($controller, $action))) { diff --git a/src/Controleur/QuizController.php b/src/Controleur/QuizController.php index fc148ee..cfa51cf 100644 --- a/src/Controleur/QuizController.php +++ b/src/Controleur/QuizController.php @@ -116,7 +116,6 @@ class QuizController $idquestion = $question->getIdQuestion(); echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]); - } public function getNumberOfQuestion() : int diff --git a/src/Controleur/VisitorControler.php b/src/Controleur/VisitorControler.php index 1c18f50..40a3c9c 100644 --- a/src/Controleur/VisitorControler.php +++ b/src/Controleur/VisitorControler.php @@ -15,6 +15,8 @@ Class VisitorControler { private UserModel $mdl; + private array $errors; + /** * @throws SyntaxError * @throws RuntimeError @@ -41,6 +43,9 @@ Class VisitorControler { case "signin": $this -> visitorSignIn(); break; + case "valid": + $this -> toSignIn(); + break; default: break; } @@ -66,8 +71,6 @@ Class VisitorControler { */ public function visitorLogIn(): void { - - global $vues; global $twig; echo $twig->render("login.html.twig"); @@ -87,8 +90,7 @@ Class VisitorControler { { if (password_verify($mdp, $user->getPassword())) { - $_SESSION['pseudo'] = $pseudo; - $_SESSION['email'] = $user->getEmail(); + $_SESSION['user'] = $pseudo; header("Location: /"); } else die(); /* Afficher Erreur Mot de passe */ @@ -105,16 +107,22 @@ Class VisitorControler { */ public function visitorSignIn(): void { - global $vues; global $twig; echo $twig->render("signin.html.twig"); - - $this -> toSignIn(); } + /** + * @throws RuntimeError + * @throws SyntaxError + * @throws LoaderError + */ public function toSignIn() : void { + global $twig; + + $this -> errors = [null, null, null]; + if ($_POST) { $pseudo = $_POST['pseudo'] ?? null; $email = $_POST['email'] ?? null; @@ -122,21 +130,30 @@ Class VisitorControler { $cmdp = $_POST['cmdp'] ?? null; if ($mdp != $cmdp) { - die(); /* Afficher Erreur Mot de passe */ + $this->errors[2] = "Mots de passe incorrects"; + //$this->visitorSignIn(); + echo $twig->render("signin.html.twig", ['error' => $this->errors]); + exit(); } - $option = ['cost' => 12]; $hmdp = password_hash($mdp, PASSWORD_BCRYPT, $option); $isUserAlreadyUsed = $this -> mdl -> getUsername($pseudo); $isEmailAlreadyUsed = $this -> mdl -> getEmail($email); - if ($isUserAlreadyUsed || $isEmailAlreadyUsed) - die(); /* Afficher Message Erreur */ + if ($isUserAlreadyUsed) { + $this->errors[0] = "Pseudo déjà utilisé"; + echo $twig->render("signin.html.twig", ['error' => $this->errors]); + exit(); + } + else if ($isEmailAlreadyUsed) { + $this->errors[1] = "Email déjà utilisé"; + echo $twig->render("signin.html.twig", ['error' => $this->errors]); + exit(); + } else echo $this->mdl->insertUser($pseudo, $email, $hmdp); $_SESSION["pseudo"] = $pseudo; - $_SESSION["email"] = $email; header("Location: /"); } diff --git a/vue/templates/login.html.twig b/vue/templates/login.html.twig index d292540..1012770 100644 --- a/vue/templates/login.html.twig +++ b/vue/templates/login.html.twig @@ -29,14 +29,14 @@

Identifiant *

- +

Mot de passe *

- +
-

Vous n'avez pas de compte?

- S'incrire +

Vous n'avez de compte?

+ S'incrire
diff --git a/vue/templates/signin.html.twig b/vue/templates/signin.html.twig index f74b234..3e73db4 100644 --- a/vue/templates/signin.html.twig +++ b/vue/templates/signin.html.twig @@ -26,31 +26,34 @@

▶ S'inscrire ◀

- +

Identifiant *

- + + {% if error[0] != null %} +

{{ error[0] }}

+ {% endif %}

Email *

- + + {% if error[1] != null %} +

{{ error[1] }}

+ {% endif %}

Mot de passe *

- - {% if errors %} -
{{ errors }}
- {% endif %} +

Confirmer mot de passe *

- - {% if errors %} -
{{ errors }}
+ + {% if error[2] != null %} +

{{ error[2] }}

{% endif %}
@@ -60,7 +63,7 @@
- +
diff --git a/vue/templates/signin2.html.twig b/vue/templates/signin2.html.twig new file mode 100644 index 0000000..87c65a3 --- /dev/null +++ b/vue/templates/signin2.html.twig @@ -0,0 +1,62 @@ + + + + + + + Wiki Fantasy : Inscription + + + + + +
+
+ + +
+ user +
+
+
+

▶ z{{ test }} aeazrazeraz ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ +
+ +
+

Confirmer mot de passe *

+ +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ + \ No newline at end of file