specific exception when no login info found in session

This commit is contained in:
Gilles Crettenand
2015-06-19 11:13:51 +02:00
parent 15cdf4082b
commit e68e7db123
2 changed files with 7 additions and 2 deletions

View File

@@ -12,4 +12,5 @@ class AuthenticationException extends WebException {
const USER_NOT_FOUND = 200; const USER_NOT_FOUND = 200;
const BAD_LOGIN = 201; const BAD_LOGIN = 201;
const AUTHENTICATION_FAILED = 202; const AUTHENTICATION_FAILED = 202;
const LOGIN_EMPTY = 203;
} }

View File

@@ -13,7 +13,7 @@ use BSR\Lib\WebService;
class NetBiblio extends WebService class NetBiblio extends WebService
{ {
/** @var string $version version number */ /** @var string $version version number */
public static $version = '1.1.0'; public static $version = '1.1.1';
private $login = ''; private $login = '';
private $client = 'website'; private $client = 'website';
@@ -28,7 +28,7 @@ class NetBiblio extends WebService
*/ */
private function CheckSession() private function CheckSession()
{ {
if (! isset ($_SESSION["user"]["login"])) { if (! isset ($_SESSION["user"]["login"]) || empty($_SESSION["user"]["login"])) {
return; return;
} }
@@ -53,6 +53,10 @@ class NetBiblio extends WebService
$this->checkSession(); $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); $user = User::find($this->login);
if (!$user) { if (!$user) {