diff --git a/CHANGES.md b/CHANGES.md index 00194492..20a83dc8 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,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 captach 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/module/user/user.php b/core/module/user/user.php index 73751843..5d465942 100755 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -334,15 +334,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 */ @@ -363,7 +380,7 @@ 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 ]); @@ -415,7 +432,7 @@ class user extends common { } else { // Valeurs en sortie $this->addOutput([ - 'notification' => 'Connexion réussie', + 'notification' => 'Bienvenue ' . $this->getData(['user',$userId,'firstname']) . ' ' . $this->getData(['user',$userId,'lastname']) , 'redirect' => helper::baseUrl() . str_replace('_', '/', str_replace('__', '#', $this->getUrl(2))), 'state' => true ]); @@ -433,7 +450,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)