From 0ca949d9586ded61bbb3b90be8d29df74730515c Mon Sep 17 00:00:00 2001 From: Bess1k Date: Fri, 16 Jan 2026 09:45:00 +0100 Subject: [PATCH 01/10] Update inscription.php --- app/views/inscription.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/views/inscription.php b/app/views/inscription.php index 5fca6a7..4430b37 100644 --- a/app/views/inscription.php +++ b/app/views/inscription.php @@ -1,11 +1,4 @@ - - - - Connexion — Folliow - - -
@@ -179,6 +172,4 @@
- - From 90887a380a9d01e3355809c0c416c7c65fc4cf37 Mon Sep 17 00:00:00 2001 From: Bess1k Date: Fri, 16 Jan 2026 09:45:43 +0100 Subject: [PATCH 02/10] Update connexion.php --- app/views/connexion.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/views/connexion.php b/app/views/connexion.php index f5be81c..42f25cf 100644 --- a/app/views/connexion.php +++ b/app/views/connexion.php @@ -1,9 +1,5 @@ - - - - Connexion — Folliow - + @@ -101,7 +97,4 @@ - - - From 97a504edd7167c237dba220125cc6263b000e662 Mon Sep 17 00:00:00 2001 From: Bess1k Date: Fri, 16 Jan 2026 14:18:48 +0100 Subject: [PATCH 03/10] Create user_controller.php --- app/controllers/user_controller.php | 139 ++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 app/controllers/user_controller.php diff --git a/app/controllers/user_controller.php b/app/controllers/user_controller.php new file mode 100644 index 0000000..9f20be7 --- /dev/null +++ b/app/controllers/user_controller.php @@ -0,0 +1,139 @@ + 0) { + // Vérifier le formulaire + if ($strMail == ""){ + $arrError['mail'] = "Le mail est obligatoire"; + } + if ($strPwd == ""){ + $arrError['pwd'] = "Le mot de passe est obligatoire"; + } + + // Si le formulaire est rempli correctement + if (count($arrError) == 0){ + // Vérifier l'utilisateur en BDD + $objUserModel = new UserModel; + $arrResult = $objUserModel->verifUser($strMail, $strPwd); + //var_dump($arrResult); + if ($arrResult === false){ // Si la base de données ne renvoie rien + $arrError[] = "Mail ou mot de passe invalide"; + }else{ + // Ajoute l'utilisateur en session + /*$_SESSION['firstname'] = $arrResult['user_firstname']; + $_SESSION['name'] = $arrResult['user_name']; + $_SESSION['id'] = $arrResult['user_id'];*/ + // j'enlève le mot de passe avant la session + //unset($arrResult['user_pwd']); + $_SESSION['user'] = $arrResult; + $_SESSION['success'] = "Bienvenue, vous êtes bien connecté"; + + header("Location:index.php"); + exit; + //var_dump($_SESSION); + //var_dump("Connecté"); + } + } + } + include("../app/views/login.php"); + include("../app/views/partials/footer.php"); + + } + + + public function logout(){ + session_start(); + /*session_destroy(); + session_start();*/ + + // on supprime l'utilisateur en session + unset($_SESSION['user']); + + $_SESSION['success'] = "Vous êtes bien déconnecté"; + + header("Location:index.php"); + exit; + + } + + public function register() + { + // inclusion du header + include("../app/views/partials/header.php"); + + // Création de l'entity User + $objUser = new User(); + + $strPseudo = $_POST['user_pseudo'] ?? ""; + $strPwdConfirm = $_POST['pwd_confirm'] ?? ""; + + // Tableau des erreurs + $arrError = []; + + // Traitement du formulaire + if (count($_POST) > 0) { + + // Hydratation depuis le formulaire + $objUser->setName($_POST['user_name'] ?? ""); + $objUser->setFirstname($_POST['user_firstname'] ?? ""); + $objUser->setMail($_POST['user_mail'] ?? ""); + $objUser->setPwd($_POST['user_password'] ?? ""); + + // Tester le formulaire + if ($objUser->getName() == "") { + $arrError['user_name'] = "Le nom est obligatoire"; + } + + if ($objUser->getFirstname() == "") { + $arrError['user_firstname'] = "Le prénom est obligatoire"; + } + + if ($objUser->getMail() == "") { + $arrError['user_mail'] = "Le mail est obligatoire"; + } + + if ($strPseudo == "") { + $arrError['user_pseudo'] = "Le pseudo est obligatoire"; + } + + if ($objUser->getPwd() == "") { + $arrError['user_password'] = "Le mot de passe est obligatoire"; + } elseif ($objUser->getPwd() != $strPwdConfirm) { + $arrError['pwd_confirm'] = "Les mots de passe ne correspondent pas"; + } + + // Si le formulaire est rempli correctement + if (count($arrError) == 0) { + $objUserModel = new UserModel(); + $boolInsert = $objUserModel->insert($objUser, $strPseudo); + + if ($boolInsert === true) { + $_SESSION['success'] = "Compte créé avec succès"; + header("Location:index.php?ctrl=user&action=login"); + exit; + } else { + $arrError[] = "Erreur lors de l'ajout"; + } + } + } + + // inclusions les fichiers inscription et footer + include("../app/views/inscription.php"); + include("../app/views/partials/footer.php"); + } + + +} + From 4cb0e9ec7619bc81c59dcba5936b363df2b014a6 Mon Sep 17 00:00:00 2001 From: Bess1k Date: Mon, 19 Jan 2026 15:33:32 +0100 Subject: [PATCH 04/10] Update user_controller.php --- app/controllers/user_controller.php | 59 +++++++++++++++++------------ 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/app/controllers/user_controller.php b/app/controllers/user_controller.php index 9f20be7..2831c67 100644 --- a/app/controllers/user_controller.php +++ b/app/controllers/user_controller.php @@ -68,72 +68,83 @@ class UserCtrl{ } - public function register() - { - // inclusion du header + public function signin(){ + + // Inclusion du header include("../app/views/partials/header.php"); - // Création de l'entity User + // Entité pour réafficher les valeurs dans le formulaire $objUser = new User(); - $strPseudo = $_POST['user_pseudo'] ?? ""; - $strPwdConfirm = $_POST['pwd_confirm'] ?? ""; + // Récupération des champs (mêmes "name=" que dans le formulaire) + $strPwdConfirm = $_POST['pwd_confirm'] ?? ""; - // Tableau des erreurs + // Tableau d'erreurs (clé = champ, valeur = message) $arrError = []; - // Traitement du formulaire - if (count($_POST) > 0) { + // Traitement du formulaire uniquement si POST + if (!empty($_POST)) { - // Hydratation depuis le formulaire + // Hydratation "manuelle" (ou via hydrate si tu l'as) $objUser->setName($_POST['user_name'] ?? ""); $objUser->setFirstname($_POST['user_firstname'] ?? ""); $objUser->setMail($_POST['user_mail'] ?? ""); + $objUser->setPseudo($_POST['user_pseudo'] ?? ""); $objUser->setPwd($_POST['user_password'] ?? ""); + + // Champs optionnels : on les stocke aussi même si ils sont vides + $objUser->setPhone($_POST['user_phone'] ?? ""); + $objUser->setWork($_POST['user_work'] ?? ""); + $objUser->setLocation($_POST['user_location'] ?? ""); + $objUser->setDescription($_POST['user_description'] ?? ""); - // Tester le formulaire - if ($objUser->getName() == "") { + + // --- VALIDATIONS (obligatoires) --- + if (trim($objUser->getName()) === "") { $arrError['user_name'] = "Le nom est obligatoire"; } - if ($objUser->getFirstname() == "") { + if (trim($objUser->getFirstname()) === "") { $arrError['user_firstname'] = "Le prénom est obligatoire"; } - if ($objUser->getMail() == "") { + if (trim($objUser->getMail()) === "") { $arrError['user_mail'] = "Le mail est obligatoire"; + } elseif (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)) { + $arrError['user_mail'] = "Le format du mail n'est pas correct"; } - if ($strPseudo == "") { + if (trim($objUser->getPseudo()) === "") { $arrError['user_pseudo'] = "Le pseudo est obligatoire"; } - if ($objUser->getPwd() == "") { + if (trim($objUser->getPwd()) === "") { $arrError['user_password'] = "Le mot de passe est obligatoire"; - } elseif ($objUser->getPwd() != $strPwdConfirm) { - $arrError['pwd_confirm'] = "Les mots de passe ne correspondent pas"; + } elseif ($objUser->getPwd() !== $strPwdConfirm) { + $arrError['pwd_confirm'] = "Le mot de passe et sa confirmation ne sont pas identiques"; } - // Si le formulaire est rempli correctement - if (count($arrError) == 0) { + // Si pas d'erreurs => insertion + if (count($arrError) === 0) { $objUserModel = new UserModel(); - $boolInsert = $objUserModel->insert($objUser, $strPseudo); + $boolInsert = $objUserModel->insert($objUser); if ($boolInsert === true) { $_SESSION['success'] = "Compte créé avec succès"; header("Location:index.php?ctrl=user&action=login"); exit; } else { - $arrError[] = "Erreur lors de l'ajout"; + // Erreur globale (pas liée à un champ) + $arrError['global'] = "Erreur lors de l'ajout"; } } } - // inclusions les fichiers inscription et footer + // Affichage de la vue inscription (alert + formulaire) include("../app/views/inscription.php"); include("../app/views/partials/footer.php"); } -} +} From 45e80ea4d3d8277b273b67390135e4c6ea4ede0f Mon Sep 17 00:00:00 2001 From: Bess1k Date: Mon, 19 Jan 2026 15:34:39 +0100 Subject: [PATCH 05/10] Create user_model.php --- app/models/user_model.php | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 app/models/user_model.php diff --git a/app/models/user_model.php b/app/models/user_model.php new file mode 100644 index 0000000..706931b --- /dev/null +++ b/app/models/user_model.php @@ -0,0 +1,88 @@ +_db->query($strRq)->fetchAll(); + } + + /** + * @param string $strMail + * @param string $strPwd + * @return array|bool + */ + public function verifUser(string $strMail, string $strPwd):array|bool{ + // 2. Construire la requête + $strRq = "SELECT user_id, user_name, user_firstname, user_password, user_image + FROM users + WHERE user_mail = '".$strMail."'"; + // Récupère mon utilisateur + // Executer la requête et récupérer les résultats + $arrUser = $this->_db->query($strRq)->fetch(); + // Vérification du mot de passe haché + if (password_verify($strPwd, $arrUser['user_password'])){ + // Renvoi l'utilisateur + unset($arrUser['user_password']); // on enlève le pwd + return $arrUser; + }else{ + return false; + } + } + + //public function insert(string $strName, string $strFirstname, string $strMail, string $strPwd):int{ + /** + * Fonction d'insertion d'un utilisateur en BDD + * @param object $objUser L'objet utilisateur + * @return bool Est-ce que la requête s'est bien passée (true/false) + */ + public function insert(object $objUser):bool{ + + // 2. Construire la requête + /*$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd) + VALUES ('".$objUser->getName()."', + '".$objUser->getFirstname()."', + '".$objUser->getMail()."', + '".$objUser->getPwdHash()."')";*/ + $strRq = "INSERT INTO users (user_name, user_firstname, user_pseudo, user_mail, user_password, user_phone, user_work, user_location, user_description) + VALUES (:name, :firstname, :pseudo,:mail, :pwd, :phone, :work, :location,:description)"; + // Préparer la requête + $rqPrep = $this->_db->prepare($strRq); + // Donne les informations + $rqPrep->bindValue(":name", $objUser->getName(), PDO::PARAM_STR); + $rqPrep->bindValue(":firstname", $objUser->getFirstname(), PDO::PARAM_STR); + $rqPrep->bindValue(":pseudo", $objUser->getPseudo(), PDO::PARAM_STR); + $rqPrep->bindValue(":mail", $objUser->getMail(), PDO::PARAM_STR); + $rqPrep->bindValue(":pwd", $objUser->getPwdHash(), PDO::PARAM_STR); + $rqPrep->bindValue(':phone', $objUser->getPhone() ?? "", PDO::PARAM_STR); + $rqPrep->bindValue(':work', $objUser->getWork() ?? "", PDO::PARAM_STR); + $rqPrep->bindValue(':location', $objUser->getLocation() ?? "", PDO::PARAM_STR); + $rqPrep->bindValue(':description', $objUser->getDescription() ?? "", PDO::PARAM_STR); + + + + // 3. Executer la requête + //var_dump($strRq);die; + //return $db->exec($strRq); + return $rqPrep->execute(); + } + } From 20de0c40fb5cbe7509517ebb3c002415445da2ca Mon Sep 17 00:00:00 2001 From: Bess1k Date: Mon, 19 Jan 2026 15:35:23 +0100 Subject: [PATCH 06/10] Update inscription.php --- app/views/inscription.php | 327 ++++++++++++++++++++------------------ 1 file changed, 172 insertions(+), 155 deletions(-) diff --git a/app/views/inscription.php b/app/views/inscription.php index 4430b37..9b4f3ec 100644 --- a/app/views/inscription.php +++ b/app/views/inscription.php @@ -1,175 +1,192 @@ + +
- -
- - -
+ +
- +
- -

Inscription

+ +

Inscription

+

+ Créez votre compte utilisateur. +

- -

- Créez votre compte utilisateur. -

- - - -
- -
- - -
- - -
- - -
- - -
- - -
- -
- @ - + + -
+ - -
- - -
+ + + - -
- - -
+
- -
- - -
+ +
+ + +
- -
- - -
+ +
+ + +
- -
- - -
+ +
+ +
+ @ + +
+
- -
- - -
+ +
+ + +
- -
- -
+ +
+ + +
- -
- - Déjà un compte ? - Se connecter - -
+ +
+ + +
+ + +
+ + +
-
- + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ +
+
-
-
- - + +
From 9b6e92d95be915d57ae94402a9046c6e2d42773f Mon Sep 17 00:00:00 2001 From: Yass <102179445+Yasder5@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:49:05 +0100 Subject: [PATCH 07/10] Add files via upload --- app/entity/user_entity.php | 124 +++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 app/entity/user_entity.php diff --git a/app/entity/user_entity.php b/app/entity/user_entity.php new file mode 100644 index 0000000..5e19525 --- /dev/null +++ b/app/entity/user_entity.php @@ -0,0 +1,124 @@ +_prefix = 'user_'; + } + + public function getId():int{ + return $this->_id; + } + public function setId(int $id){ + $this->_id = $id; + } + + public function getName():string{ + return $this->_name; + } + public function setName(string $name){ + $this->_name = $name; + } + + public function getFirstname():string{ + return $this->_firstname; + } + public function setFirstname(string $firstname){ + $this->_firstname = $firstname; + } + + public function getPseudo():string{ + return $this->_pseudo; + } + public function setPseudo(string $pseudo){ + $this->_pseudo = $pseudo; + } + + public function getImage():string{ + return $this->_image; + } + public function setImage(string $image){ + $this->_image = $image; + } + + public function getMail():string{ + return $this->_mail; + } + public function setMail(string $mail){ + $this->_mail = strtolower($mail); + } + + public function getPwd():string{ + return $this->_pwd; + } + public function getPwdHash():string{ + return password_hash($this->_pwd, PASSWORD_DEFAULT); + } + public function setPwd(string $pwd){ + $this->_pwd = $pwd; + } + + public function getPhone():string{ + return $this->_phone; + } + public function setPhone(string $phone){ + $this->_phone = $phone; + } + + public function getWork():string{ + return $this->_work; + } + public function setWork(string $work){ + $this->_work = $work; + } + + public function getBirth():string{ + return $this->_birth; + } + public function setBirth(string $birth){ + $this->_birth = $birth; + } + + public function getLocation():string{ + return $this->_location; + } + public function setLocation(string $location){ + $this->_location = $location; + } + + public function getDescription():string{ + return $this->_description; + } + public function setDescription(string $description){ + $this->_description = $description; + } + + public function getAccountCreation():string{ + return $this->_account_creation; + } + public function setAccountCreation(string $account_creation){ + $this->_account_creation = $account_creation; + } + + public function getStatus():int{ + return $this->_status; + } + public function setStatus(int $status){ + $this->_status = $status; + } + } From d362107768725614c02a745f9346313f60f2ff4f Mon Sep 17 00:00:00 2001 From: Bess1k Date: Mon, 19 Jan 2026 15:54:03 +0100 Subject: [PATCH 08/10] Update inscription.php --- app/views/inscription.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/inscription.php b/app/views/inscription.php index 9b4f3ec..e52b5b3 100644 --- a/app/views/inscription.php +++ b/app/views/inscription.php @@ -174,6 +174,14 @@ rows="3" > + + +
+ + Déjà un compte ? + Se connecter + +
From 9e132b507223bbe762f945d84ddd0ad04822e8bc Mon Sep 17 00:00:00 2001 From: Bess1k Date: Mon, 19 Jan 2026 21:16:40 +0100 Subject: [PATCH 09/10] Update connexion.php --- app/views/connexion.php | 165 ++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 83 deletions(-) diff --git a/app/views/connexion.php b/app/views/connexion.php index 42f25cf..aba0f13 100644 --- a/app/views/connexion.php +++ b/app/views/connexion.php @@ -1,100 +1,99 @@ + +
- - - - -
- - -
+ +
- -

Connexion

+

Connexion

- -

- Connectez-vous à votre compte. -

+

+ Connectez-vous à votre compte. +

- - -
- -
- - -
- - -
- - -
- - -
- - -
-
- - + + -
+ - -
- -
+ + - -
- - Pas encore de compte ? - Créer un compte - -
+
- - + +
+ + +
-
- + +
+ + +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+ + Pas encore de compte ? + Créer un compte + +
+ + + +
+
- -
+
+
From b1965065a5c31cfece67a89ec5a4b27b9689aa48 Mon Sep 17 00:00:00 2001 From: Bess1k Date: Tue, 20 Jan 2026 08:58:01 +0100 Subject: [PATCH 10/10] Update user_controller.php --- app/controllers/user_controller.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/user_controller.php b/app/controllers/user_controller.php index 2831c67..7ec6c18 100644 --- a/app/controllers/user_controller.php +++ b/app/controllers/user_controller.php @@ -76,16 +76,16 @@ class UserCtrl{ // Entité pour réafficher les valeurs dans le formulaire $objUser = new User(); - // Récupération des champs (mêmes "name=" que dans le formulaire) + // Récupération des champs $strPwdConfirm = $_POST['pwd_confirm'] ?? ""; - // Tableau d'erreurs (clé = champ, valeur = message) + // Tableau d'erreurs $arrError = []; // Traitement du formulaire uniquement si POST if (!empty($_POST)) { - // Hydratation "manuelle" (ou via hydrate si tu l'as) + // Hydratation $objUser->setName($_POST['user_name'] ?? ""); $objUser->setFirstname($_POST['user_firstname'] ?? ""); $objUser->setMail($_POST['user_mail'] ?? ""); @@ -118,12 +118,16 @@ class UserCtrl{ $arrError['user_pseudo'] = "Le pseudo est obligatoire"; } - if (trim($objUser->getPwd()) === "") { + $strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{16,}$/"; + if ($objUser->getPwd() == ""){ $arrError['user_password'] = "Le mot de passe est obligatoire"; - } elseif ($objUser->getPwd() !== $strPwdConfirm) { + }else if (!preg_match($strRegex, $objUser->getPwd())){ + $arrError['user_password'] = "Le mot de passe ne correspond pas aux règles"; + }else if($objUser->getPwd() != $strPwdConfirm){ $arrError['pwd_confirm'] = "Le mot de passe et sa confirmation ne sont pas identiques"; } + // Si pas d'erreurs => insertion if (count($arrError) === 0) { $objUserModel = new UserModel(); @@ -140,7 +144,7 @@ class UserCtrl{ } } - // Affichage de la vue inscription (alert + formulaire) + // Affichage de la vue inscription include("../app/views/inscription.php"); include("../app/views/partials/footer.php"); }