diff options
Diffstat (limited to 'src/View/LoginBuilder.php')
| -rw-r--r-- | src/View/LoginBuilder.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/View/LoginBuilder.php b/src/View/LoginBuilder.php new file mode 100644 index 0000000..3a303b0 --- /dev/null +++ b/src/View/LoginBuilder.php | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | <?php | ||
| 2 | // src/View/LoginBuilder.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | namespace App\View; | ||
| 7 | |||
| 8 | use App\Entity\Node; | ||
| 9 | use App\Service\URL; | ||
| 10 | use App\Service\Captcha; | ||
| 11 | |||
| 12 | class LoginBuilder extends AbstractBuilder | ||
| 13 | { | ||
| 14 | public function __construct(Node $node) | ||
| 15 | { | ||
| 16 | // déjà connecté? | ||
| 17 | if(IS_ADMIN) | ||
| 18 | { | ||
| 19 | header('Location: ' . new URL); | ||
| 20 | die; | ||
| 21 | } | ||
| 22 | |||
| 23 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | ||
| 24 | |||
| 25 | $captcha = new Captcha; | ||
| 26 | $_SESSION['captcha'] = $captcha->getSolution(); // enregistrement de la réponse du captcha pour vérification | ||
| 27 | |||
| 28 | //$this->html .= $header; | ||
| 29 | |||
| 30 | $error_messages = [ | ||
| 31 | 'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.', | ||
| 32 | 'captcha_server_error' => 'captcha_server_error', | ||
| 33 | 'bad_solution_captcha' => 'Erreur au test anti-robot, veuillez réessayer.', | ||
| 34 | 'bad_login_or_password' => 'Mauvais identifiant ou mot de passe, veuillez réessayer.', // ne pas indiquer où est l'erreur | ||
| 35 | 'forbidden_characters' => 'Caractères interdits: espaces, tabulations, sauts CR/LF.' | ||
| 36 | ]; | ||
| 37 | |||
| 38 | $link_form = new URL(['action' => 'connection']); | ||
| 39 | isset($_GET['from']) ? $link_form->addParams(['from' => $_GET['from']]) : ''; | ||
| 40 | isset($_GET['id']) ? $link_form->addParams(['id' => $_GET['id']]) : ''; | ||
| 41 | |||
| 42 | $link_exit = new URL; | ||
| 43 | isset($_GET['from']) ? $link_exit->addParams(['page' => $_GET['from'] ]) : ''; | ||
| 44 | isset($_GET['id']) ? $link_exit->addParams(['id' => $_GET['id']]) : ''; | ||
| 45 | |||
| 46 | $error = isset($_GET['error']) ? $error_messages[$_GET['error']] : ''; | ||
| 47 | |||
| 48 | ob_start(); | ||
| 49 | require $viewFile; | ||
| 50 | $this->html = ob_get_clean(); // nouveau contenu | ||
| 51 | |||
| 52 | //$this->html .= <p style='color: red;'>Ce site utilise un cookie « obligatoire » lorsque vous êtes connecté ainsi que sur cette page.<br>Il sera supprimé à votre déconnexion ou dès que vous aurez quitté le site.</p>; | ||
| 53 | |||
| 54 | //$this->html .= $footer; | ||
| 55 | } | ||
| 56 | } | ||
