diff --git a/module/fid/src/Service/Client.php b/module/fid/src/Service/Client.php index 8251bda89799c286cb4467bcb60aceb25a5412a8..c1bcdac820d41fd2a222198e45e794f00726bca0 100644 --- a/module/fid/src/Service/Client.php +++ b/module/fid/src/Service/Client.php @@ -452,10 +452,14 @@ class Client * @param String $permission Name of the permission * @param User|null $user user object or null if we want to validate the currently logged in user * @throws ClientException + * @throws UserNotLoggedinException * @throws UserNotAuthorizedException */ protected function authorize(String $permission,User $user = null) { + if (!$this->isLoggedOn()) { + throw new UserNotLoggedinException(); + } $user = $this->requestUserDetails(); if (!$user->hasPermission($permission)) { throw new UserNotAuthorizedException(); @@ -472,7 +476,7 @@ class Client try { $this->authorize($permission); - } catch (UserNotAuthorizedException $exception) { + } catch (UserAuthorizationException $exception) { return FALSE; } return TRUE; diff --git a/module/fid/src/Service/UserAuthorizationException.php b/module/fid/src/Service/UserAuthorizationException.php new file mode 100644 index 0000000000000000000000000000000000000000..33d2772ba94072b56c4e95fb33714e3b6c65ead1 --- /dev/null +++ b/module/fid/src/Service/UserAuthorizationException.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (C) 2019 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + +namespace fid\Service; + +class UserAuthorizationException extends \Exception +{ +} diff --git a/module/fid/src/Service/UserNotAuthorizedException.php b/module/fid/src/Service/UserNotAuthorizedException.php index a802c48c66a9517551223bea7644e50c2fe066f1..8d7dadc44f1c4589b18d7c01062d720583cd0547 100644 --- a/module/fid/src/Service/UserNotAuthorizedException.php +++ b/module/fid/src/Service/UserNotAuthorizedException.php @@ -21,6 +21,6 @@ namespace fid\Service; -class UserNotAuthorizedException extends \Exception +class UserNotAuthorizedException extends UserAuthorizationException { } diff --git a/module/fid/src/Service/UserNotLoggedinException.php b/module/fid/src/Service/UserNotLoggedinException.php new file mode 100644 index 0000000000000000000000000000000000000000..dced38c128d139e60562b60f3466af2aede2a373 --- /dev/null +++ b/module/fid/src/Service/UserNotLoggedinException.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright (C) 2019 Leipzig University Library + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Sebastian Kehr <kehr@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2 + */ + +namespace fid\Service; + +class UserNotLoggedinException extends UserAuthorizationException +{ +} diff --git a/module/finc/sql/migrations/mysql/migrateData_Vufind1ToVufind5_Common.sql b/module/finc/sql/migrations/mysql/migrateData_Vufind1ToVufind5_Common.sql index 9ceed22977ca574ace181db8df926e8b7aab8635..8717ced29bc9fefe0b4a026e64f43bd22ce87678 100644 --- a/module/finc/sql/migrations/mysql/migrateData_Vufind1ToVufind5_Common.sql +++ b/module/finc/sql/migrations/mysql/migrateData_Vufind1ToVufind5_Common.sql @@ -52,16 +52,6 @@ ALTER TABLE user ADD COLUMN last_login timestamp NOT NULL DEFAULT '2000-01-01 00:00:00', ADD COLUMN auth_method varchar(50) DEFAULT NULL; --- Drop columns - -ALTER TABLE user - DROP COLUMN username_id; - --- Apply constraint modifications - -ALTER TABLE user - DROP INDEX user_id_key; - ALTER TABLE user ADD UNIQUE(username), ADD UNIQUE(cat_id);