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.

38 lines
922 B

<?php
require('gatewayAdmins.php');
require('config.php');
class MdlAdmin
{
public function connection($login, $mdp){
$gateway = new GatewayAdmin(new Connection($dsn,$user,$pass));
if(password_verify($mdp,$gatewayAdmin->getCredential($login))){
$_SESSION['role']='admin';
$_SESSION['login']=$login;
return new Admin($login,$role);
}
else{
return NULL;
}
}
public function déconnexion(){
session_unset();
session_destroy();
$_SESSION = array();
}
public function isAdmin(){
if(isset $_SESSION['login'] && isset $_SESSION['role']) {
$login = Nettoyer::nettoyer_string($_SESSION['login']);
$role = Nettoyer::nettoyer_string($_SESSION['role']);
return new Admin($login,$role)
}
else{
return null;
}
}
}