specific exception when no login info found in session

master
Gilles Crettenand 11 years ago
parent 15cdf4082b
commit e68e7db123

@ -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;
} }

@ -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) {

Loading…
Cancel
Save