Skip to content
Snippets Groups Projects
Commit 2e4985ad authored by Dorian Merz's avatar Dorian Merz
Browse files

Merge branch 'instance/fid' into instance/fid_adlr

parents 247ff8cf 7111474d
No related merge requests found
......@@ -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;
......
<?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
{
}
......@@ -21,6 +21,6 @@
namespace fid\Service;
class UserNotAuthorizedException extends \Exception
class UserNotAuthorizedException extends UserAuthorizationException
{
}
<?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
{
}
......@@ -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);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment