From 285d830ca3bb06dd23d9b6308a18767782c40889 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sun, 26 May 2019 17:07:03 +0200 Subject: [PATCH] =?UTF-8?q?[9.1.07]=20V=C3=A9rification=20de=20saisie=20cr?= =?UTF-8?q?=C3=A9ation=20d'un=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/module/user/user.php | 40 +++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/core/module/user/user.php b/core/module/user/user.php index 57c35317..ed167dd7 100755 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -32,36 +32,44 @@ class user extends common { public function add() { // Soumission du formulaire if($this->isPost()) { + $check=true; // L'identifiant d'utilisateur est indisponible $userId = $this->getInput('userAddId', helper::FILTER_ID, true); if($this->getData(['user', $userId])) { self::$inputNotices['userAddId'] = 'Identifiant déjà utilisé'; + $check=false; } // Double vérification pour le mot de passe - $mail = true; if($this->getInput('userAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('userAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) { self::$inputNotices['userAddConfirmPassword'] = 'Incorrect'; - $mail = false; + $check = false; } // Crée l'utilisateur $userFirstname = $this->getInput('userAddFirstname', helper::FILTER_STRING_SHORT, true); $userLastname = $this->getInput('userAddLastname', helper::FILTER_STRING_SHORT, true); $userMail = $this->getInput('userAddMail', helper::FILTER_MAIL, true); - $this->setData([ - 'user', - $userId, - [ - 'firstname' => $userFirstname, - 'forgot' => 0, - 'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true), - 'lastname' => $userLastname, - 'mail' => $userMail, - 'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true) - ] - ]); - // Envoi le mail + // Pas de nom saisi + if (empty($userFirstname) || empty($userLastname)) { + $check=false; + } + // Si tout est ok création effective + if ($check === true) { + $this->setData([ + 'user', + $userId, + [ + 'firstname' => $userFirstname, + 'forgot' => 0, + 'group' => $this->getInput('userAddGroup', helper::FILTER_INT, true), + 'lastname' => $userLastname, + 'mail' => $userMail, + 'password' => $this->getInput('userAddPassword', helper::FILTER_PASSWORD, true) + ] + ]); + } + // Envoie le mail $sent = true; - if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $mail === true) { + if($this->getInput('userAddSendMail', helper::FILTER_BOOLEAN) && $check === true) { $sent = $this->sendMail( $userMail, 'Compte créé sur ' . $this->getData(['config', 'title']),