ajout d'un sel de hashage
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent 86c3d2eaa4
commit 44a829eac2

@ -19,7 +19,8 @@ class Model
}
}
public function signUp() {
public function signUp()
{
global $rep, $vues, $sel, $error;
try {
$validation = new Validation();
@ -40,23 +41,22 @@ class Model
$error = "Email déjà utilisé.";
throw (new Exception("Email déjà utilisé"));
}
$password = password_hash($_REQUEST['password'], PASSWORD_DEFAULT);
$password = password_hash($_REQUEST['password'] . $sel, PASSWORD_DEFAULT);
$Utilisateur = new Utilisateur($_REQUEST['email'], $_REQUEST['username'], $password, false);
$this->utilisateur_gateway->insert($Utilisateur);
$_SESSION['connected'] = 'true';
$_SESSION['role'] = 'utilisateur';
require($rep . $vues['main']);
}catch (PDOException $e)
{
} catch (PDOException $e) {
$error = "Erreur de connexion à la base de données.";
require($rep . $vues['erreur']);
}
catch (Exception $e){
} catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
public function login(){
public function login()
{
global $rep, $vues, $sel, $error;
try {
$Utilisateur = $this->utilisateur_gateway->getUtilisateurByEmail($_REQUEST['email']);
@ -65,15 +65,14 @@ class Model
throw new Exception("Utilisateur introuvable");
}
$mdp = $this->utilisateur_gateway->getMdpByEmail($_REQUEST['email']);
if (password_verify($mdp, $_REQUEST['password'])){
if (password_verify($mdp, $_REQUEST['password'] . $sel)) {
$error = "Mot de passe incorrect.";
throw new Exception("Mot de passe invalide");
}
$estAdmin = $this->utilisateur_gateway->getEstAdminByEmail($_REQUEST['email']);
if ($estAdmin == true) {
$_SESSION['role'] = "admin";
}
else{
} else {
$_SESSION['role'] = "utilisateur";
}
@ -84,7 +83,8 @@ class Model
}
}
public function goToPresentation() {
public function goToPresentation()
{
global $rep, $vues, $error;
try {
require($rep . $vues['presentation']);
@ -94,7 +94,8 @@ class Model
}
}
public function goToHome() {
public function goToHome()
{
global $rep, $vues, $error;
try {
require($rep . $vues['main']);
@ -104,7 +105,8 @@ class Model
}
}
public function goToLogin() {
public function goToLogin()
{
global $rep, $vues, $error;
try {
require($rep . $vues['login']);
@ -114,7 +116,8 @@ class Model
}
}
public function goToSignUp() {
public function goToSignUp()
{
global $rep, $vues, $error;
try {
require($rep . $vues['signUp']);
@ -124,7 +127,8 @@ class Model
}
}
public function goToEnigme() {
public function goToEnigme()
{
global $rep, $vues, $error;
try {
require($rep . $vues['enigme']);
@ -134,7 +138,8 @@ class Model
}
}
public function goToQueue() {
public function goToQueue()
{
global $rep, $vues, $error;
try {
require($rep . $vues['Queue']);

Binary file not shown.

@ -3,20 +3,6 @@ require_once('./Config/Config.php');
require_once('./Config/Autoload.php');
Autoload::charger();
// $db = new Connection();
// $stm=$db->prepare("INSERT INTO Utilisateur VALUES (:email, :password, :pseudo, :admin)");
// $stm->bindValue(':email', "e",SQLITE3_TEXT);
// $stm->bindValue(':password', "e" ,SQLITE3_TEXT);
// $stm->bindValue(':pseudo', "e", SQLITE3_TEXT);
// $stm->bindValue(':admin', 0, SQLITE3_INTEGER);
// $stm->execute();
// $res = $db->query('SELECT * FROM Utilisateur');
// Select all the users in the database
// while ($row = $res->fetchArray()) {
// echo $row['email'] . " " . $row['password'] . " " . $row['pseudo'] . " " . $row['admin'] . " ";
// }
$control = new FrontController();
//session_regenerate_id(true);

Loading…
Cancel
Save