diff --git a/Source/.htaccess b/Source/.htaccess index b840088..ffd584f 100644 --- a/Source/.htaccess +++ b/Source/.htaccess @@ -10,4 +10,5 @@ RewriteRule ^continueResponse$ index.php?page=continueResponse [L] RewriteRule ^createForm$ index.php?page=createForm [L] RewriteRule ^addKeyword$ index.php?page=addKeyword [L] RewriteRule "goToAdmin" index.php?page=goToAdmin [L] -RewriteRule ^goToAdminLogin$ index.php?page=goToAdminLogin [L] \ No newline at end of file +RewriteRule ^goToAdminLogin$ index.php?page=goToAdminLogin [L] +RewriteRule ^login$ index.php?page=login [L] \ No newline at end of file diff --git a/Source/API/script/Gateway/GatewayAdmin.php b/Source/API/script/Gateway/GatewayAdmin.php index a93b9be..bae26fc 100644 --- a/Source/API/script/Gateway/GatewayAdmin.php +++ b/Source/API/script/Gateway/GatewayAdmin.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use PDO; /** diff --git a/Source/API/script/Gateway/GatewayKeyword.php b/Source/API/script/Gateway/GatewayKeyword.php index b68381c..4a08f44 100644 --- a/Source/API/script/Gateway/GatewayKeyword.php +++ b/Source/API/script/Gateway/GatewayKeyword.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use PDO; /** diff --git a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php index 902f792..46ffa7a 100644 --- a/Source/API/script/Gateway/GatewayListResponseOfCandidate.php +++ b/Source/API/script/Gateway/GatewayListResponseOfCandidate.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use PDO; /** diff --git a/Source/API/script/Gateway/GatewayPossibleResponse.php b/Source/API/script/Gateway/GatewayPossibleResponse.php index 7f3280d..ce1cd71 100644 --- a/Source/API/script/Gateway/GatewayPossibleResponse.php +++ b/Source/API/script/Gateway/GatewayPossibleResponse.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use PDO; /** diff --git a/Source/API/script/Gateway/GatewayQuestion.php b/Source/API/script/Gateway/GatewayQuestion.php index fc4e768..8d0ed0b 100644 --- a/Source/API/script/Gateway/GatewayQuestion.php +++ b/Source/API/script/Gateway/GatewayQuestion.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use BusinessClass\BoxQuestion; use BusinessClass\Question; use BusinessClass\TextQuestion; diff --git a/Source/API/script/Gateway/GatewayResponse.php b/Source/API/script/Gateway/GatewayResponse.php index 114f4b0..12b28bf 100644 --- a/Source/API/script/Gateway/GatewayResponse.php +++ b/Source/API/script/Gateway/GatewayResponse.php @@ -2,7 +2,7 @@ namespace API\script\Gateway; -use API\script\Config\Connection; +use Config\Connection; use PDO; /** diff --git a/Source/Config/Validate.php b/Source/Config/Validate.php index 87ec18f..c65e3c0 100644 --- a/Source/Config/Validate.php +++ b/Source/Config/Validate.php @@ -98,4 +98,10 @@ class Validate global $responseMaxLength; return (strlen($response) <= $responseMaxLength); } + public static function username(string $username): bool + { + global $usernameMaxLength; + return (strlen($username) >= 3 && preg_match("#[a-zA-Z0-9]+#", $username) && strlen($username) <= $usernameMaxLength); + } + } diff --git a/Source/Controller/ControllerCandidate.php b/Source/Controller/ControllerCandidate.php index 52ed5f8..d0aed40 100644 --- a/Source/Controller/ControllerCandidate.php +++ b/Source/Controller/ControllerCandidate.php @@ -3,6 +3,7 @@ namespace Controller; use Model\ModelCandidate; +use Exception; /** * Permet de controller les réponses à fournir en fonction des actions passer dans l'URL @@ -38,4 +39,21 @@ class ControllerCandidate { (new ModelCandidate())->submitForm(); } + public function login() :void { + global $rep,$views; + try{ + $model= new ModelCandidate(); + $model->login(); + if($_SESSION['role'] == "Admin") { + require_once($rep . $views['validLogin']); + } + else + { + require_once($rep . $views['adminLogin']); + } + } catch (Exception $e) { + $error = $e->getMessage(); + require_once($rep . $views['adminLogin']); + } + } } diff --git a/Source/Controller/FrontController.php b/Source/Controller/FrontController.php index 86448a0..8c0666d 100644 --- a/Source/Controller/FrontController.php +++ b/Source/Controller/FrontController.php @@ -67,5 +67,6 @@ class FrontController { $this->router->map('POST','/addKeyword',array($controller['Admin'],'addKeyword'),'addKeyword'); $this->router->map('GET','/goToAdmin',array($controller['Admin'],'goToAdmin'),'goToAdmin'); $this->router->map('GET','/goToAdminLogin',array($controller['Candidate'],'goToAdminLogin'),'goToLogin'); + $this->router->map('POST','/login',array($controller['Candidate'],'login'),'login'); } } diff --git a/Source/Exceptions/InexistantIdentifierException.php b/Source/Exceptions/InexistantIdentifierException.php new file mode 100644 index 0000000..0f7f604 --- /dev/null +++ b/Source/Exceptions/InexistantIdentifierException.php @@ -0,0 +1,13 @@ +