From aaf0e1c459915c03b042c66c0eebc0b013ffdf5b Mon Sep 17 00:00:00 2001 From: fredtempez Date: Wed, 30 Dec 2020 17:41:27 +0100 Subject: [PATCH] merge 10313 --- .gitignore | 9 +++++++++ CHANGES.md | 1 + core/core.php | 5 +---- core/module/user/user.php | 41 ++++++++++++++++++++++++++++----------- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 7404a186..3da2b58a 100755 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,12 @@ site/data/journal.log .DS_Store site/.DS_Store site/file/.DS_Store +site/data/es/locale.json +site/data/es/module.json +site/data/es/page.json +site/data/en/locale.json +site/data/en/module.json +site/data/en/page.json +site/data/de/locale.json +site/data/de/module.json +site/data/de/page.json diff --git a/CHANGES.md b/CHANGES.md index ed499d77..3c1f2b98 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ Modifications : - Message d'erreur littéral. - Sauvegarde des fichiers de données après un effacement et une écriture. - Google Analytics, option d'anonymisation. + - Procédure de connexion : les erreurs de captcha sont comptabilisées comme des échecs, allégement des messages d'information. Correction : - Notification de commentaire, nom de la page incorrect. diff --git a/core/core.php b/core/core.php index cfe4fa0a..a12d1605 100755 --- a/core/core.php +++ b/core/core.php @@ -83,6 +83,7 @@ class common { public static $inputBefore = []; public static $inputNotices = []; public static $importNotices = []; + public static $captchaNotices = []; public static $coreNotices = []; public $output = [ 'access' => true, @@ -2833,10 +2834,6 @@ class layout extends common { foreach (common::$coreNotices as $item) $notification .= $item . ' | '; $notificationClass = 'notificationError'; } - if(common::$inputNotices) { - $notification = 'Impossible de soumettre le formulaire, car il contient des erreurs'; - $notificationClass = 'notificationError'; - } elseif(empty($_SESSION['ZWII_NOTIFICATION_SUCCESS']) === false) { $notification = $_SESSION['ZWII_NOTIFICATION_SUCCESS']; $notificationClass = 'notificationSuccess'; diff --git a/core/module/user/user.php b/core/module/user/user.php index 4288af48..8f01c904 100755 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -366,15 +366,32 @@ class user extends common { public function login() { // Soumission du formulaire if($this->isPost()) { - // Check la captcha + // Lire Id du compte + $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); + // Check le captcha if( $this->getData(['config','connect','captcha']) AND password_verify($this->getInput('userLoginCaptcha', helper::FILTER_INT), $this->getInput('userLoginCaptchaResult') ) === false ) { - self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; + //self::$inputNotices['userLoginCaptcha'] = 'Incorrect'; + $notification = 'Captcha incorrect !'; + // Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec + if ($this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) { + $this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); + } + // Cas 2 la limite du nombre de connexion est atteinte : placer le timer + if ( $this->getdata(['user',$userId,'connectFail']) == $this->getData(['config', 'connect', 'attempt']) ) { + $this->setData(['user',$userId,'connectTimeout', time()]); + } + // Cas 3 le délai de bloquage court + if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() ) { + $notification = 'Accès bloqué ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; + } + // Valeurs en sortie + $this->addOutput([ + 'notification' => $notification + ]); } else { - // Lire Id du compte - $userId = $this->getInput('userLoginId', helper::FILTER_ID, true); /** * Aucun compte existant */ @@ -395,14 +412,14 @@ class user extends common { AND in_array($this->getData(['blacklist',$userId,'ip']),$ipBlackList) ) { // Valeurs en sortie $this->addOutput([ - 'notification' => 'Trop de tentatives, compte verrouillé', + 'notification' => 'Compte verrouillé', 'redirect' => helper::baseUrl(), 'state' => false ]); } else { // Valeurs en sortie $this->addOutput([ - 'notification' => 'Identifiant ou mot de passe incorrect' + 'notification' => 'Identifiant ou mot de passe incorrects' ]); } /** @@ -423,6 +440,9 @@ class user extends common { AND password_verify($this->getInput('userLoginPassword', helper::FILTER_STRING_SHORT, true), $this->getData(['user', $userId, 'password'])) AND $this->getData(['user', $userId, 'group']) >= self::GROUP_MEMBER ) { + // RAZ + $this->setData(['user',$userId,'connectFail',0 ]); + $this->setData(['user',$userId,'connectTimeout',0 ]); // Expiration $expire = $this->getInput('userLoginLongTime') ? strtotime("+1 year") : 0; $c = $this->getInput('userLoginLongTime', helper::FILTER_BOOLEAN) === true ? 'true' : 'false'; @@ -444,15 +464,14 @@ class user extends common { } else { // Valeurs en sortie $this->addOutput([ - 'notification' => 'Connexion réussie', - 'redirect' => helper::baseUrl(), - //'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), + 'notification' => 'Bienvenue ' . $this->getData(['user',$userId,'firstname']) . ' ' . $this->getData(['user',$userId,'lastname']) , + 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), 'state' => true ]); } // Sinon notification d'échec } else { - $notification = 'Identifiant ou mot de passe incorrect'; + $notification = 'Identifiant ou mot de passe incorrects'; // Cas 1 le nombre de connexions est inférieur aux tentatives autorisées : incrément compteur d'échec if ($this->getData(['user',$userId,'connectFail']) < $this->getData(['config', 'connect', 'attempt'])) { $this->setData(['user',$userId,'connectFail',$this->getdata(['user',$userId,'connectFail']) + 1 ]); @@ -463,7 +482,7 @@ class user extends common { } // Cas 3 le délai de bloquage court if ($this->getData(['user',$userId,'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time() ) { - $notification = 'Trop de tentatives, accès bloqué durant ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; + $notification = 'Accès bloqué ' . ($this->getData(['config', 'connect', 'timeout']) / 60) . ' minutes.'; } // Journalisation $dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true)