From e68e7db123cb3cca871e1dc897c03a2b990e41d7 Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Fri, 19 Jun 2015 11:13:51 +0200 Subject: [PATCH] specific exception when no login info found in session --- Lib/Exception/AuthenticationException.php | 1 + NetBiblio.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/Exception/AuthenticationException.php b/Lib/Exception/AuthenticationException.php index 66a8c0f..3f5cb47 100644 --- a/Lib/Exception/AuthenticationException.php +++ b/Lib/Exception/AuthenticationException.php @@ -12,4 +12,5 @@ class AuthenticationException extends WebException { const USER_NOT_FOUND = 200; const BAD_LOGIN = 201; const AUTHENTICATION_FAILED = 202; + const LOGIN_EMPTY = 203; } \ No newline at end of file diff --git a/NetBiblio.php b/NetBiblio.php index c651b0c..d122503 100644 --- a/NetBiblio.php +++ b/NetBiblio.php @@ -13,7 +13,7 @@ use BSR\Lib\WebService; class NetBiblio extends WebService { /** @var string $version version number */ - public static $version = '1.1.0'; + public static $version = '1.1.1'; private $login = ''; private $client = 'website'; @@ -28,7 +28,7 @@ class NetBiblio extends WebService */ private function CheckSession() { - if (! isset ($_SESSION["user"]["login"])) { + if (! isset ($_SESSION["user"]["login"]) || empty($_SESSION["user"]["login"])) { return; } @@ -53,6 +53,10 @@ class NetBiblio extends WebService $this->checkSession(); + if(strlen($this->login) == 0) { + throw new AuthenticationException("LoginEmpty", "No login information found in session.", AuthenticationException::LOGIN_EMPTY); + } + $user = User::find($this->login); if (!$user) {