Skip to content
Snippets Groups Projects
Commit ecc94112 authored by Robert Lange's avatar Robert Lange
Browse files

refs #21486 [fid] introduce rules for get-it-box

* usage of rules evaluator and GetItRules.yaml in instance
* add temp check with old implementation - TODO: remove with 22011

* fix status on invalid session state, also refs #22043
** throw UserNotAuthorizedException on 401
** on 401 logout in RecordController homeAction
parent 2f4c606e
No related merge requests found
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
;#################################################################### ;####################################################################
Logout = Abmelden Logout = Abmelden
invalid_session = "Ihre Sitzung ist abgelaufen oder ungültig. Bitte melden Sie sich erneut an, um alle Funktionen nutzen zu können."
Username = E-Mail-Adresse Username = E-Mail-Adresse
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
Username = Email address Username = Email address
back_to_form = "back to previous form" back_to_form = "back to previous form"
invalid_session = "Your session is invalid or has expired. Please log in again to be able to use all functions."
; DBIS / Licenses ; DBIS / Licenses
dbis_hint = "Notice" dbis_hint = "Notice"
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
*/ */
namespace fid\Controller; namespace fid\Controller;
use fid\Service\UserNotAuthorizedException;
/** /**
* Record Controller * Record Controller
* *
...@@ -46,4 +48,27 @@ class RecordController extends \finc\Controller\RecordController ...@@ -46,4 +48,27 @@ class RecordController extends \finc\Controller\RecordController
public const SUBITO_ARTICLE = "subito-article"; public const SUBITO_ARTICLE = "subito-article";
public const SUBITO_PARTIAL_COPY = "subito-partial-copy"; public const SUBITO_PARTIAL_COPY = "subito-partial-copy";
public const DIGITIZATION = "digitization"; public const DIGITIZATION = "digitization";
/**
* Home (default) action -- forward to requested (or default) tab.
*
* @return mixed
*/
public function homeAction()
{
try {
if ($this->client->isLoggedOn()
&& !$this->client->requestUserDetails(null, true)
) {
$this->client->logoff();
$this->flashMessenger()->addErrorMessage('invalid_session');
}
} catch (UserNotAuthorizedException $e) {
$this->client->logoff();
$retval = parent::homeAction();
$this->flashMessenger()->addErrorMessage('invalid_session');
return $retval;
}
return parent::homeAction();
}
} }
...@@ -89,6 +89,9 @@ class Client ...@@ -89,6 +89,9 @@ class Client
/* @var string */ /* @var string */
protected $locale = 'en'; protected $locale = 'en';
/* @var Client */
public static $instance;
/** /**
* Client constructor. * Client constructor.
* *
...@@ -119,6 +122,7 @@ class Client ...@@ -119,6 +122,7 @@ class Client
$this->uriFactory = $uriFactory; $this->uriFactory = $uriFactory;
$this->streamFactory = $streamFactory; $this->streamFactory = $streamFactory;
$this->requestFactory = $requestFactory; $this->requestFactory = $requestFactory;
Client::$instance = $this;
} }
/** /**
...@@ -502,6 +506,10 @@ class Client ...@@ -502,6 +506,10 @@ class Client
$request = $this->buildRequest('get', "users/$userId"); $request = $this->buildRequest('get', "users/$userId");
$response = $this->sendAuthenticatedRequest($request); $response = $this->sendAuthenticatedRequest($request);
if ($response->getStatusCode() === 401) {
throw new UserNotAuthorizedException();
}
if ($response->getStatusCode() !== 200) { if ($response->getStatusCode() !== 200) {
$this->throwException($response); $this->throwException($response);
} }
...@@ -852,6 +860,10 @@ class Client ...@@ -852,6 +860,10 @@ class Client
$request = $this->buildRequest('post', 'logons', $body); $request = $this->buildRequest('post', 'logons', $body);
$response = $this->sendAuthenticatedRequest($request, false); $response = $this->sendAuthenticatedRequest($request, false);
if ($response->getStatusCode() === 401) {
throw new UserNotAuthorizedException();
}
if ($response->getStatusCode() !== 201) { if ($response->getStatusCode() !== 201) {
$this->throwException($response); $this->throwException($response);
} }
......
...@@ -67,7 +67,8 @@ class Factory ...@@ -67,7 +67,8 @@ class Factory
return new GetIt( return new GetIt(
$container->get('VuFind\Config')->get('getit'), $container->get('VuFind\Config')->get('getit'),
$container->get(Client::class), $container->get(Client::class),
$container->get('VuFind\Role\PermissionManager') $container->get('VuFind\Role\PermissionManager'),
$container->get('VuFind\YamlReader')->get('GetItRules.yaml')
); );
} }
} }
This diff is collapsed.
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