|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
namespace model;
|
|
|
|
|
|
|
|
|
|
use config\Validation;
|
|
|
|
|
use DAL\AdminGateway;
|
|
|
|
|
use DAL\Connection;
|
|
|
|
|
use metier\Admin;
|
|
|
|
@ -12,17 +13,19 @@ class AdminModel
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
*/
|
|
|
|
|
public function connection (string $username, string $mdp){
|
|
|
|
|
//Validation::validationLogin($username);
|
|
|
|
|
//Validation::validationMdp($mdp);
|
|
|
|
|
|
|
|
|
|
$gwArticle = new AdminGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
|
|
|
$lmdp = $gwArticle->login($username);
|
|
|
|
|
|
|
|
|
|
foreach ($lmdp as $motDePasse){
|
|
|
|
|
if (true){//password_verify($mdp,$motDePasse['password']) or $mdp == $motDePasse['password']){
|
|
|
|
|
$_SESSION['role'] = 'admin';
|
|
|
|
|
$_SESSION['pseudo'] = $username;
|
|
|
|
|
return new Admin($username,$motDePasse['mail']);
|
|
|
|
|
$gwArticle = new AdminGateway(new Connection('mysql:host=londres.uca.local;dbname=dbrorossetto','rorossetto','tpphp'));
|
|
|
|
|
if (Validation::validationLogin($username)){
|
|
|
|
|
$lmdp = $gwArticle->login($username);
|
|
|
|
|
}
|
|
|
|
|
if(Validation::validationMdp($mdp)){
|
|
|
|
|
foreach ($lmdp as $motDePasse){
|
|
|
|
|
if (password_verify($mdp,$motDePasse['password']) or $mdp == $motDePasse['password']){
|
|
|
|
|
$_SESSION['role'] = 'admin';
|
|
|
|
|
$_SESSION['pseudo'] = $username;
|
|
|
|
|
return new Admin($username,$motDePasse['mail']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|