|
|
|
@ -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']);
|
|
|
|
|