executerRequete($sql, array($login)); if ($utilisateur->rowCount() == 1) { $user = $utilisateur->fetch(PDO::FETCH_ASSOC); $hash = $user['motPass']; return (password_verify($mdp, $hash)); } else return false; } public function getUtilisateur($login) { $sql = "call sp_p_get_utilisateur(?);"; $utilisateur = $this->executerRequete($sql, array($login)); if ($utilisateur->rowCount() == 1) // return $utilisateur->fetch(PDO::FETCH_ASSOC); return $utilisateur->fetch(PDO::FETCH_ASSOC); else throw new Exception("Aucun utilisateur ne correspond aux identifiants fournis"); } public function changerpass($login, $ancmdp, $nvmdp) { $hash = password_hash($nvmdp, PASSWORD_DEFAULT); $sql = "call sp_p_changer_mot_passe_prestataire(?, ?)"; $this->executerRequete($sql, array($hash, $login)); $_SESSION['p_passExpired'] = false; $_SESSION['p_passAchanger'] = false; } public function viderTablesTemporairesUser($login) { $idSaisie = $_SESSION['p_idSaisie']; $sql = "call sp_p_viderTablesTemporairesUser(?, ?)"; $this->executerRequete($sql, array($login, $idSaisie)); } public function getUtilisateurIdsaisie($idSaisie) { $sql = "call sp_p_get_utilisateur_idSaisie(?);"; $utilisateur = $this->executerRequete($sql, array($idSaisie)); return $utilisateur->fetch(PDO::FETCH_ASSOC); } public function changerlangueutilisateur() { $user = $_SESSION['p_login']; $codeLangue = $_SESSION['p_lang']; if($codeLangue == "en_US") { $codeNewLang = "fr_FR"; } else { $codeNewLang = "en_US"; } $sql = "call sp_p_changer_langue_utilisateur(?, ?);"; $this->executerRequete($sql, array($user, $codeNewLang)); $_SESSION['p_lang'] = $codeNewLang; setcookie('lang', $codeNewLang, time()+365*24*3600, '/'); $_SESSION['p_lang'] = $codeNewLang; } public function verifiermotpassdefaut($codeSociete, $mdp) { $sql = "call sp_get_mot_pass_reinit(?);"; $resultat = $this->executerRequete($sql, array($codeSociete)); if ($resultat->rowCount() == 1) { $user = $resultat->fetch(PDO::FETCH_ASSOC); $hash = $user['motPassReinit']; return (password_verify($mdp, $hash)); } else { return false; } } public function alowed_ip($login, $ipConnexion) { $sql = 'select fn_alowed_ip_prestataire(?, ?) AS alowedIp;'; $resultat = $this->executerRequete($sql, array($login, $ipConnexion)); $ligne = $resultat->fetch(PDO::FETCH_ASSOC); return $ligne['alowedIp']; } public function changerlangueutilisateurconnexion($login, $codeNewLang) { $sql = "call sp_p_changer_langue_utilisateur(?, ?);"; $this->executerRequete($sql, array($login, $codeNewLang)); $_SESSION['p_lang'] = $codeNewLang; setcookie('lang', $codeNewLang, time()+365*24*3600, '/'); $_COOKIE['lang'] = $codeNewLang; } public function set_otp_value($login, $otpValue) { $hash = password_hash($otpValue, PASSWORD_DEFAULT); $sql = 'UPDATE p_utilisateur SET otpValue=? WHERE codeutilisateur=?;'; $this->executerRequete($sql, array($hash, $login)); } public function get_otp_value($login) { $sql = 'SELECT otpValue FROM p_utilisateur WHERE codeutilisateur=?;'; $resultat = $this->executerRequete($sql, array($login)); $ligne = $resultat->fetch(PDO::FETCH_ASSOC); return $ligne['otpValue']; } public function envoyer_otp($login, $otpValue) { $sql = 'CALL sp_p_envoyer_otp(?, ?, ?);'; $this->executerRequete($sql, array($_SESSION['p_codeSociete'], $login, $otpValue)); } }