You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
961 B
35 lines
961 B
<?php
|
|
|
|
namespace model;
|
|
|
|
use DAL\AdminGateway;
|
|
use DAL\Connection;
|
|
use metier\Admin;
|
|
|
|
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 (password_verify($mdp,$motDePasse['password']) or $mdp == $motDePasse['password']){
|
|
$_SESSION['role'] = 'admin';
|
|
$_SESSION['pseudo'] = $username;
|
|
return new Admin($username,$motDePasse['mail']);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static function isAdmin(): bool
|
|
{
|
|
return isset($_SESSION['role']) && $_SESSION['role'] == 'admin';
|
|
}
|
|
} |