From cd82ffc09590b516d903ee0bfdd8e11aae42ab7a Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 4 Jul 2016 11:29:48 +0200 Subject: [PATCH] Avancement sur le manager 'Authentification' --- manager/Authentification.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/manager/Authentification.php b/manager/Authentification.php index 2b0b931..3e10f30 100644 --- a/manager/Authentification.php +++ b/manager/Authentification.php @@ -54,9 +54,9 @@ $_SESSION['AUTH'] = array(); - /* (4) On retourne le niveau d'authentification + /* (4) On vérifie l'authentification par BDD ---------------------------------------------------------*/ - return authLevel(); + return self::check(); } @@ -69,13 +69,32 @@ public static function check(){ /* [1] Si aucune authentification =========================================================*/ + if( authLevel() == 0 ) + return true; /* [2] Si authentification unique =========================================================*/ + if( authLevel() >= 1 ){ + $checkRoot = new Repo('warehouse/getByToken', array($_SESSION['AUTH'][0])); + + // Si le token n'existe pas + if( $checkRoot->answer() === false ) + return false; + } /* [3] Si authentification double =========================================================*/ + if( authLevel() >= 2 ){ + $checkBranch = new Repo('admin/getByToken', array($_SESSION['AUTH'][1])); + // Si le token n'existe pas + if( $checkBranch->answer() === false ) + return false; + } + + /* [3] Si pas d'erreur d'authentification, on retourne TRUE + =========================================================*/ + return true; }