diff --git a/fluxRSS/DAL/AdminGateway.php b/fluxRSS/DAL/AdminGateway.php index f2b06c0..16e6ab3 100755 --- a/fluxRSS/DAL/AdminGateway.php +++ b/fluxRSS/DAL/AdminGateway.php @@ -2,6 +2,8 @@ namespace DAL; +use PDO; + class AdminGateway { private $con; @@ -17,8 +19,8 @@ class AdminGateway public function login(string $login):array { try{ - $query = 'SELECT mdp,mail FROM Admin WHERE login = :login;'; - $this->con->executeQuery($query, array(':flux' => array($login, PDO::PARAM_STR))); + $query = 'SELECT password,mail FROM Admin WHERE name = :login;'; + $this->con->executeQuery($query, array(':login' => array($login, PDO::PARAM_STR))); return $this->con->getResults(); }catch (\PDOException $e){ throw new \Exception("PDO error"); diff --git a/fluxRSS/cache/7d/7d23d818a9618a39f1bf95b3e694ad5c44a32007fb7602bc4dc5cebe7a55ad13.php b/fluxRSS/cache/7d/7d23d818a9618a39f1bf95b3e694ad5c44a32007fb7602bc4dc5cebe7a55ad13.php index 1dcc316..7de6a2c 100755 --- a/fluxRSS/cache/7d/7d23d818a9618a39f1bf95b3e694ad5c44a32007fb7602bc4dc5cebe7a55ad13.php +++ b/fluxRSS/cache/7d/7d23d818a9618a39f1bf95b3e694ad5c44a32007fb7602bc4dc5cebe7a55ad13.php @@ -12,7 +12,7 @@ use Twig\Sandbox\SecurityNotAllowedFunctionError; use Twig\Source; use Twig\Template; -/* vuephp1.html */ +/* connexion.html */ class __TwigTemplate_2ce784f5b9085065b66af58be97997ff169e0f0d71d95a1d280acea4a24fd4e6 extends Template { private $source; @@ -165,7 +165,7 @@ utilisation anormale de la vuephp public function getTemplateName() { - return "vuephp1.html"; + return "connexion.html"; } public function isTraitable() @@ -180,6 +180,6 @@ utilisation anormale de la vuephp public function getSourceContext() { - return new Source("", "vuephp1.html", "/Applications/MAMP/htdocs/phptwig/templates/vuephp1.html"); + return new Source("", "connexion.html", "/Applications/MAMP/htdocs/phptwig/templates/connexion.html"); } } diff --git a/fluxRSS/controleur/Controleur.php b/fluxRSS/controleur/Controleur.php index f9084b4..0786850 100755 --- a/fluxRSS/controleur/Controleur.php +++ b/fluxRSS/controleur/Controleur.php @@ -3,6 +3,7 @@ namespace controleur; use model\AdminModel; use model\ArticleModel; +use model\Parser; class Controleur { @@ -31,13 +32,17 @@ class Controleur $this->ValidationFormulaire($dVueEreur); break; - //mauvaise action - default: + case 'vueArticle': $tabArticle[] = ArticleModel::getArticles(); $dVueEreur[] = "Erreur d'appel php"; $dataview = ['Article'=> $tabArticle]; echo $twig->render('listArticle.html', ['tabArticle' => $dataview, 'dVueErreur'=>$dVueEreur]); break; + //mauvaise action + default: + $dVueEreur[] = "Erreur d'appel php"; + echo $twig->render('listArticle.html', ['dVueErreur'=>$dVueEreur]); + break; } } catch (\PDOException $e) { //si erreur BD, pas le cas ici @@ -52,6 +57,11 @@ class Controleur exit(0); }//fin constructeur + /** + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError + * @throws \Twig\Error\LoaderError + */ public function login(){ global $twig; // nécessaire pour utiliser variables globales if ($_SERVER['REQUEST_METHOD'] === 'POST') { @@ -63,7 +73,7 @@ class Controleur if ($admin != null){ $dVue = [ - 'data' => ArticleModel::getArticles() + 'data' => Parser::getArticles() ]; echo $twig->render('listArticle.html', [ 'dVue' => $dVue @@ -80,7 +90,7 @@ class Controleur $dVue = [ 'data' => ArticleModel::getArticles() ]; - echo $twig->render('vuephp1.html', [ + echo $twig->render('connexion.html', [ 'dVue' => $dVue ]); } @@ -105,6 +115,6 @@ class Controleur //'data' => $data, ]; - echo $twig->render('vuephp1.html', ['dVue' => $dVue, 'dVueEreur' => $dVueEreur]); + echo $twig->render('connexion.html', ['dVue' => $dVue, 'dVueEreur' => $dVueEreur]); } }//fin class diff --git a/fluxRSS/model/AdminModel.php b/fluxRSS/model/AdminModel.php index df3ece6..1767d1b 100755 --- a/fluxRSS/model/AdminModel.php +++ b/fluxRSS/model/AdminModel.php @@ -2,19 +2,24 @@ namespace model; +use DAL\AdminGateway; +use DAL\Connection; use metier\Admin; class AdminModel { + /** + * @throws \Exception + */ public function connection (string $username, string $mdp){ //Validation::validationLogin($login); //Validation::validationMdp($mdp); - $gwArticle = new AdminGateway(new Connection('mysql:host= londres.uca.local ; dbname= dbrorossetto', 'rorossetto', 'tpphp')); + $gwArticle = new AdminGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto', 'rorossetto', 'tpphp')); $lmdp = $gwArticle->login($username); foreach ($lmdp as $motDePasse){ - if (password_verify($mdp,$motDePasse['mdp'])){ + if (password_verify($mdp,$motDePasse['password']) or $mdp == $motDePasse['password']){ $_SESSION['role'] = 'admin'; $_SESSION['pseudo'] = $username; return new Admin($username,$motDePasse['mail']); diff --git a/fluxRSS/templates/connexion.html b/fluxRSS/templates/connexion.html new file mode 100755 index 0000000..7e71bbe --- /dev/null +++ b/fluxRSS/templates/connexion.html @@ -0,0 +1,58 @@ + + +
+ + +{{value}}
+ {% endfor %} + {% endif %} + {% endif %} + +- {% for article in value} + {% for article in value %}
{{article}}
diff --git a/fluxRSS/templates/vuephp1.html b/fluxRSS/templates/vuephp1.html deleted file mode 100755 index 64cdea5..0000000 --- a/fluxRSS/templates/vuephp1.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -{{ error }}
-{% endif %} - - - -Not a member? Go to Articles - -