public function login() { // connexion au site if (isset($_SESSION['user'])) { $this->redirectToRoute('accueil'); // si ok envoie page 2 } if (isset($_POST['connexion'])) { $auth = new AuthentificationManager(); $userManager = new UserManager(); $UserManagerSuite = new GeneralManager(); //debug($userManager); die; // vérification if ($auth->isValidLoginInfo($_POST['wuser']['mail'], $_POST['wuser']['mot_de_passe'])) { //selection table user $user_part1 = $userManager->getUserByUsernameOrEmail($_POST['wuser']['mail']); //recuperation de l'id de l'utilisateur connecté et jointure avec les autres tables. $id_user = $user_part1['id']; if ($user_part1['validation_inscription'] === 'true') { $user_part2 = $UserManagerSuite->findAllLogUser($id_user); $user = array_merge($user_part1, $user_part2); // ajout de $user2 dans $user $auth->logUserIn($user); //debug($_SESSION['user']);die(); // vérification $this->redirectToRoute('accueil'); } else { $this->show('home/home'); } } } $this->show('home/home'); }
public function loginUser() { // Affecter une variable à chaque valeur clé de $_POST $email = trim(htmlentities($_POST['email'])); $password = trim(htmlentities($_POST['password'])); // Initialisation d'un tableau d'erreurs (associatif) $errors = []; // Instanciation d'un object de type UserManager $userManager = new UserManager(); $userManager->setTable('users'); // Bug du framework le nom de la table est mal défini $resultUser = $userManager->getUserByUsernameOrEmail($email); if ($resultUser) { // Instanciation d'un object de type AuthentificationManager $authentificationManager = new AuthentificationManager(); // Cette méthode teste si le mot de passe est valide, $password ici est en clair if ($authentificationManager->isValidLoginInfo($email, $password)) { $authentificationManager->logUserIn($resultUser); // Redirection $this->redirectToRoute('seekrun'); } else { $errors['login'] = "******"; } } else { $errors['login'] = "******"; } $this->show('run/seekrun', ['errors' => $errors]); }
public function deleteProfil($id) { $this->allowTo('admin'); $user_manager = new UserManager(); $user = $user_manager->find($id); // recuperation du profil a supprimer $id_wuser = $user['id']; //debug($user);debug($id_wuser);die(); $manager = new CompetenceManager(); $manager->delete($id_wuser); $manager = new DiplomeManager(); $manager->delete($id_wuser); $manager = new Experience_proManager(); $manager->delete($id_wuser); $manager = new Fil_actuManager(); $manager->delete($id_wuser); $manager = new PortfolioManager(); $manager->delete($id_wuser); $manager = new Reseaux_socialManager(); $manager->delete($id_wuser); $manager = new Reseaux_proManager(); $manager->delete($id_wuser); $manager = new Reseaux_divertissementManager(); $manager->delete($id_wuser); $manager = new UserManager(); $manager->delete($id); //reflexion sur l'envoi de mail lors d'une validation d'un mail //Helper::mail($mail, "Votre inscription n'a pas été validée sur LOTL", "Vous ne remplissez pas les conditions pour vous inscrire sur LOTL, vous pouvez toujours suivre notre communauté sur www.jesuistondev.fr"); $this->redirectToRoute('administration'); }
public function registerUser() { // debug($_POST); $email = trim(htmlentities($_POST['email'])); $name = trim(htmlentities($_POST['name'])); $password = trim(htmlentities($_POST['password'])); $confirmPassword = trim(htmlentities($_POST['confirmPassword'])); $errors = []; $userManager = new UserManager(); $userManager->setTable('users'); if (empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) == false) { $errors['email'] = "Verifiez votre adresse email"; } elseif ($userManager->emailExists($email)) { $errors['email'] = "Cet email existe déjà"; } if ($password != $confirmPassword) { $errors['password'] = "******"; } elseif (strlen($password) <= 6) { $errors['password'] = "******"; } if (empty($errors)) { $hashedPassword = password_hash($password, PASSWORD_DEFAULT); $date = new DateTime(); $resultUser = $userManager->insert(['email' => $email, 'name' => $name, 'password' => $hashedPassword, 'role' => 'member', 'created_at' => $date->format('Y-m-d H:i:s'), 'updated_at' => $date->format('Y-m-d H:i:s')]); if ($resultUser) { $authentificationManager = new AuthentificationManager(); $authentificationManager->logUserIn($resultUser); // print_r($_POST); $this->redirectToRoute('home'); } } else { $this->show('register/index', ['errors' => $errors, 'email' => $email]); } }
public function registerUser() { //debug($_POST); // Affecter une variable à chaque valeur clé de $_POST $email = trim(htmlentities($_POST['email'])); $userName = trim(htmlentities($_POST['userName'])); $password = trim(htmlentities($_POST['password'])); $confirmPassword = trim(htmlentities($_POST['confirmPassword'])); // Initialisation d'un tableau d'erreurs (associatif) $errors = []; // Instanciation d'un object de type UserManager $userManager = new UserManager(); $userManager->setTable('users'); // Bug du framework le nom de la table est mal défini // Check de l'email if (empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) { $errors['email'] = "Vérifiez votre adresse électronique."; } elseif ($userManager->emailExists($email)) { // Check en bdd que l'email existe $errors['email'] = "Cette adresse électronique existe déjà"; } // Check de l'username if (empty($userName)) { $errors['userName'] = "******"; } // Check du password if ($password != $confirmPassword) { $errors['password'] = "******"; } elseif (strlen($password) <= 5) { $errors['passwordB'] = "Votre mot de passe doit faire au moins 6 caractères"; } // S'il n'y pas d'erreurs if (empty($errors)) { // Crypter le mot de passe $hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Objet DateTime $date = new DateTime(); // Enregistrement en bdd et renvoie un tableau $resultUser = $userManager->insert(['email' => $email, 'username' => $userName, 'password' => $hashedPassword, 'role' => 'member', 'created_at' => $date->format('Y-m-d H:i:s'), 'updated_at' => $date->format('Y-m-d H:i:s')]); // debug($resultUser); // Teste que le tableau user est rempli if ($resultUser) { // Authentifier l'utilisateur car l'inscription a réussi $authentificationManager = new AuthentificationManager(); $authentificationManager->logUserIn($resultUser); // Redirection $this->redirectToRoute('home'); } } else { $this->show('register/index', ['errors' => $errors, 'email' => $email, 'username' => $userName]); } }
/** * Utilise les données utilisateurs présentes en base pour mettre à jour les données en session * @return boolean */ public function refreshUser() { $userManager = new UserManager(); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $userFromDb = $userManager->find($userFromSession['id']); if ($userFromDb) { $_SESSION["user"] = $userFromDb; return true; } } return false; }
public function login() { if (isset($_POST['create'])) { $auth = new AuthentificationManager(); $userManager = new UserManager(); if ($auth->isValidLoginInfo($_POST['myform']['username'], $_POST['myform']['password'])) { $user = $userManager->getUserByUsernameOrEmail($_POST['myform']['username']); $auth->logUserIn($user); $this->redirectToRoute('home'); } } $this->show('default/login'); }
/** * Utilise les données utilisateurs présentes en base pour mettre à jour les données en session * @return boolean */ public function refreshUser() { $app = getApp(); $userManager = new UserManager(); $userManager->setTable($app->getConfig('security_user_table')); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $userFromDb = $userManager->find($userFromSession[$app->getConfig('security_id_property')]); if ($userFromDb) { $_SESSION["user"] = $userFromDb; return true; } } return false; }
public function registerUser() { // Affecter une variable à chaque valeur clé de $_POST $email = trim(htmlentities($_POST['email'])); $password = trim(htmlentities($_POST['password'])); $passwordConfirm = trim(htmlentities($_POST['passwordConfirm'])); // Initialisation d'un tableau d'erreurs $errors = []; // Instanciation d'un object de type UserManager $userManager = new UserManager(); $userManager->setTable('users'); // Bug du framework le nom de la table est mal défini // Check de l'email if (empty($email) || filter_var($email, FILTER_VALIDATE_EMAIL) === false) { $errors['email'] = "Vérifiez votre adresse e-mail."; } elseif ($userManager->emailExists($email)) { // Check en bdd que l'email existe $errors['email'] = "Cette adresse e-mail existe déjà"; } // Check du password if ($password != $passwordConfirm) { $errors['password'] = "******"; } elseif (strlen($password) <= 6) { $errors['password'] = "******"; } // S'il n'y pas d'erreurs if (empty($errors)) { // Crypter le mot de passe $hashedPassword = password_hash($password, PASSWORD_DEFAULT); // Objet DateTime $date = new DateTime(); // Enregistrement en bdd et renvoie un tableau $resultUser = $userManager->insert(['email' => $email, 'password' => $hashedPassword, 'role' => 'member']); // debug($resultUser); // Teste que le tableau user est rempli if ($resultUser) { // Authentifier l'utilisateur car l'inscription a réussi $authentificationManager = new AuthentificationManager(); $authentificationManager->logUserIn($resultUser); // Redirection $this->redirectToRoute('login'); } } else { $this->show('register/index', ['errors' => $errors, 'email' => $email]); } }
public function profilModif() { $manager = new ProfilManager(); $manager2 = new WuserManager(); $manager3 = new UserManager(); if (isset($_POST)) { $id = $_POST['id']; $mail = $_POST['mail']; $telephone = $_POST['telephone']; $facebook = $_POST['facebook']; $twitter = $_POST['twitter']; $googleplus = $_POST['googleplus']; $linkedin = $_POST['linkedin']; $github = $_POST['github']; $profil = $manager->getUserProfil($id); if (empty($mail) || $manager3->getUserByUsernameOrEmail($mail) || !preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\\.[a-z]{2,4}\$#", $mail)) { $mail = $profil['mail']; } if (empty($telephone)) { $telephone = $profil['telephone']; } if (empty($facebook)) { $facebook = $profil['facebook']; } if (empty($twitter)) { $twitter = $profil['twitter']; } if (empty($googleplus)) { $googleplus = $profil['googleplus']; } if (empty($linkedin)) { $linkedin = $profil['linkedin']; } if (empty($github)) { $github = $profil['github']; } $manager->setProfilModif($id, $telephone, $facebook, $twitter, $googleplus, $linkedin, $github); $manager2->setWuserModif($id, $mail); $this->redirectToRoute('profil', ['id' => $id]); } }
public function refreshUserMulti() { $app = getApp(); $userManager = new UserManager(); $userManager->setTable($app->getConfig('security_user_table')); $userFromSession = $this->getLoggedUser(); if ($userFromSession) { $user_part1 = $userManager->find($userFromSession[$app->getConfig('security_id_property')]); //se connecte a la table wusers $UserManagerSuite = new GeneralManager(); $id_user = $user_part1['id']; $user_part2 = $UserManagerSuite->findAllLogUser($id_user); $userFromDb = array_merge($user_part1, $user_part2); // ajout de $user2 dans $user if ($userFromDb) { $_SESSION["user"] = $userFromDb; return true; } } return false; }
/** * Authentification */ public function auth() { // récupération d'un objet sécurité $auth = new AuthentificationManager(); // vérification login/password if ($auth->isValidLoginInfo(htmlentities($_POST['email']), htmlentities($_POST['password']) ) ) { // récupération d'un objet utilisateur $user = new UserManager; // récupération des infos de l'utilisateur en cours $util = $user->getUserByUsernameOrEmail(htmlentities($_POST['email'])); // connexion de l'utilisateur $auth->logUserIn($util); // SESSION // appel du modèle ClientManager $client = new \Manager\ClientManager(); $allClient = $client->utilisateurClient(); $_SESSION['user']['idClient'] = $allClient['id']; $_SESSION['user']['nom'] = $allClient['nomClient']; $_SESSION['user']['prenom'] = $allClient['prenomClient']; $_SESSION['user']['adresse'] = $allClient['adresseClient']; $_SESSION['user']['cp'] = $allClient['cpClient']; $_SESSION['user']['ville'] = $allClient['villeClient']; $_SESSION['user']['tel'] = $allClient['telClient']; //redirection vers une page privée $this->redirectToRoute('prive'); } else { // si non valide retour au formulaire $this->redirectToRoute('home'); } }
public function loginUser() { $email = trim(htmlentities($_POST['email'])); $password = trim(htmlentities($_POST['password'])); $errors = []; $userManager = new UserManager(); $userManager->setTable('users'); $resultUser = $userManager->getUserByUsernameOrEmail($email); // debug($resultUser); // die(); if ($resultUser) { $authentificationManager = new AuthentificationManager(); if ($authentificationManager->isValidLoginInfo($email, $password)) { $authentificationManager->logUserIn($resultUser); $this->redirectToRoute('home'); } else { $errors['login'] = "******"; } } else { $errors['login'] = "******"; } $this->show('login/index', ['errors' => $errors]); }
/** * Authentification */ public function checkLogin() { // récupération d'un objet sécurité $auth = new AuthentificationManager(); // récupération d'un objet utilisateur $user = new UserManager(); // récupération des infos de l'utilisateur en cours $util = $user->getUserByUsernameOrEmail(htmlentities($_POST['username'])); // vérification login/password if ($auth->isValidLoginInfo(htmlentities($_POST['username']), htmlentities($_POST["password"]))) { // connexion de l'utilisateur $auth->logUserIn($util); //redirection vers une page privée (ou admin, en fonction des privilèges) if ($_SESSION["user"]["role"] == "Administrateur") { $this->redirectToRoute('admin'); } else { $this->close(); $this->redirectToRoute('home'); } } else { $this->redirectToRoute('home'); } }
/** * Réinitialisation du mot de passe */ public function envoimdp() { //récupération d'un objet utilisateur $utilisateur = new \Manager\UtilisateurManager(); //création d'un objet user $user = new UserManager; //netoyage de l'email saisie $userMail = htmlentities($_POST['mailOublie']); // recup des infos de l'utilisateur grace à l'email $userInfo = $user->getUserByUsernameOrEmail($userMail); // recup de l'id utilisateur $idUser = $userInfo['id']; // generation aléatoire d'un nouveau mot de passe $newMdp = \W\Security\StringUtils::randomString(32); // création d'un tableau contenant le nouveau mot de passe // crypter avec password_hash $tUtilisateur = ['password' => password_hash($newMdp, PASSWORD_DEFAULT)]; // update dans la base $utilisateur->update($tUtilisateur, $idUser, $stripTags = true); // afficher le formulaire $this->show('utilisateur/oubliemdp', array('userMail'=>$userMail, 'mdp'=>$newMdp)); }
public function userDel($id) { $naissances = new UserManager(); $naissances->delete($id); $this->admin(); }
public function inscription_3() { if (isset($_SESSION['user'])) { $this->redirectToRoute('accueil'); // si ok envoie page 2 } if (isset($_POST['valider'])) { $_SESSION['reseaux_socialInsc'] = $_POST['reseaux_social']; $_SESSION['reseaux_proInsc'] = $_POST['reseaux_pro']; $_SESSION['reseaux_divertissementInsc'] = $_POST['reseaux_divertissement']; //nettoyage des espace en debut et fin de chaine de caractére $_SESSION['wuserInsc'] = array_map('trim', $_SESSION['wuserInsc']); $_SESSION['diplomeInsc'] = array_map('trim', $_SESSION['diplomeInsc']); $_SESSION['experience_proInsc'] = array_map('trim', $_SESSION['experience_proInsc']); $_SESSION['fil_actuInsc'] = array_map('trim', $_SESSION['fil_actuInsc']); $_SESSION['portfolioInsc'] = array_map('trim', $_SESSION['portfolioInsc']); $_SESSION['reseaux_socialInsc'] = array_map('trim', $_SESSION['reseaux_socialInsc']); $_SESSION['reseaux_proInsc'] = array_map('trim', $_SESSION['reseaux_proInsc']); $_SESSION['reseaux_divertissementInsc'] = array_map('trim', $_SESSION['reseaux_divertissementInsc']); // ajout d'un $key => $value (ex :role => membre) $_SESSION['wuserInsc']['role'] = 'membre'; $_SESSION['wuserInsc']['validation_inscription'] = 'false'; $manager = new UserManager(); // insert formulaire 1 $manager->insert($_SESSION['wuserInsc'], $stripTags = true); //enregistrement membre dans BDD $mail = $_SESSION['wuserInsc']['mail']; // recuperation du mail dans une variable //suite insert formulaire 1 $manager = new GeneralManager(); $membre = $manager->findMail($mail); //recuperation du membre dans la table wusers via le mail $id = $membre['id']; // insert page formulaire 2 $_SESSION['diplomeInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['diplome'] $manager = new DiplomeManager(); //selection de la table Diplome $manager->insert($_SESSION['diplomeInsc'], $stripTags = true); $_SESSION['experience_proInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['experience_pro'] $manager = new Experience_proManager(); //selection de la table experience_pros $manager->insert($_SESSION['experience_proInsc'], $stripTags = true); $_SESSION['competenceInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['competence'] $manager = new CompetenceManager(); //selection de la table competences $manager->insert($_SESSION['competenceInsc'], $stripTags = true); $_SESSION['fil_actuInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['fil_actu'] $manager = new Fil_actuManager(); //selection de la table fil_actus $manager->insert($_SESSION['fil_actuInsc'], $stripTags = true); $_SESSION['portfolioInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['portfolio'] $manager = new PortfolioManager(); //selection de la table portfolios $manager->insert($_SESSION['portfolioInsc'], $stripTags = true); // insert page formulaire 3 $_SESSION['reseaux_socialInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['reseaux_social'] $manager = new Reseaux_socialManager(); //selection de la table reseaux_socials $manager->insert($_SESSION['reseaux_socialInsc'], $stripTags = true); $_SESSION['reseaux_proInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['reseaux_pro'] $manager = new Reseaux_proManager(); //selection de la table reseaux_pros $manager->insert($_SESSION['reseaux_proInsc'], $stripTags = true); $_SESSION['reseaux_divertissementInsc']['id_wuser'] = $id; // ajout d'une $key id_wuser dans la SESSION['reseaux_divertissement'] $manager = new Reseaux_divertissementManager(); //selection de la table reseaux_divertissements $manager->insert($_SESSION['reseaux_divertissementInsc'], $stripTags = true); Helper::mail("*****@*****.**", "Une demande d'inscritption à été effectué sur LOTL", "Veuillez valider ou non l'inscritpion."); // l'envoi de mail vers la BAL de l'admin pour toute nouvelle demande d'inscription sur le site //destruction des SESSION INSCRIPTION $manager = new GeneralManager(); $manager->logInscrOut(); $this->redirectToRoute('validation'); } elseif (isset($_POST['precedent2'])) { $_SESSION['inscription_3'] = $_POST['inscription_3']; $this->redirectToRoute('inscription2'); // si précédent retour page 2 } $this->show('inscription/inscription3'); }
public function modif_profil3() { if (!isset($_SESSION['user'])) { $this->redirectToRoute('home'); // si ok envoie page 2 } if (isset($_POST['valider'])) { $_SESSION['reseaux_social'] = $_POST['reseaux_social']; $_SESSION['reseaux_pro'] = $_POST['reseaux_pro']; $_SESSION['reseaux_divertissement'] = $_POST['reseaux_divertissement']; //debug($_SESSION['updateUser']);debug($_SESSION['portfolio']);debug($_SESSION['reseaux_pro']);die(); //nettoyage des espace en debut et fin de chaine de caractére $_SESSION['updateUser'] = array_map('trim', $_SESSION['updateUser']); $_SESSION['diplome'] = array_map('trim', $_SESSION['diplome']); $_SESSION['experience_pro'] = array_map('trim', $_SESSION['experience_pro']); $_SESSION['fil_actu'] = array_map('trim', $_SESSION['fil_actu']); $_SESSION['portfolio'] = array_map('trim', $_SESSION['portfolio']); $_SESSION['reseaux_social'] = array_map('trim', $_SESSION['reseaux_social']); $_SESSION['reseaux_pro'] = array_map('trim', $_SESSION['reseaux_pro']); $_SESSION['reseaux_divertissement'] = array_map('trim', $_SESSION['reseaux_divertissement']); //recuperation de l'id du profil $manager = new UserManager(); $mail = $_SESSION['updateUser']['mail']; // recuperation du mail dans une variable $membre = $manager->findMail($mail); //recuperation du membre dans la table wusers via le mail $id = $membre['id']; //debug($membre);debug($id);die(); // update formulaire 1 $manager->update($_SESSION['updateUser'], $id, $stripTags = true); //enregistrement membre dans BDD // update page formulaire 2 //debug($_SESSION['diplome']);die(); $manager = new DiplomeManager(); //selection de la table Diplome $manager->update($_SESSION['diplome'], $id, $stripTags = true); $manager = new Experience_proManager(); //selection de la table experience_pros $manager->update($_SESSION['experience_pro'], $id, $stripTags = true); $manager = new CompetenceManager(); //selection de la table competences $manager->update($_SESSION['competence'], $id, $stripTags = true); $manager = new Fil_actuManager(); //selection de la table fil_actus $manager->update($_SESSION['fil_actu'], $id, $stripTags = true); $manager = new PortfolioManager(); //selection de la table portfolios $manager->update($_SESSION['portfolio'], $id, $stripTags = true); // update page formulaire 3 $manager = new Reseaux_socialManager(); //selection de la table reseaux_socials $manager->update($_SESSION['reseaux_social'], $id, $stripTags = true); $manager = new Reseaux_proManager(); //selection de la table reseaux_pros $manager->update($_SESSION['reseaux_pro'], $id, $stripTags = true); $manager = new Reseaux_divertissementManager(); //selection de la table reseaux_divertissements $manager->update($_SESSION['reseaux_divertissement'], $id, $stripTags = true); $this->redirectToRoute('accueil'); } elseif (isset($_POST['precedent2'])) { $_SESSION['inscription_3'] = $_POST['modif_profil3']; $this->redirectToRoute('modif_profil2'); // si précédent retour page 2 } $this->show('modif_profil/modif_profil3'); }
public function login() { $flagl = 0; $manager2 = new ProfilManager(); if (isset($_POST['loginform'])) { $auth = new AuthentificationManager(); $userManager = new UserManager(); if ($auth->isValidLoginInfo($_POST['myform']['mail'], $_POST['myform']['mdp'])) { $user = $userManager->getUserByUsernameOrEmail($_POST['myform']['mail']); $result = $auth->logUserIn($user); $flagl = 1; $manager2->userIsOnline($user['id']); $this->redirectToRoute('home', ['flagl' => $flagl]); } else { $error = 'Connexion impossible.'; $this->show('default/home', ['error' => $error]); } } $this->show('default/home', ['flag' => $flag]); }