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 @@
;####################################################################
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
......
......@@ -19,6 +19,7 @@
Username = Email address
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_hint = "Notice"
......
......@@ -27,6 +27,8 @@
*/
namespace fid\Controller;
use fid\Service\UserNotAuthorizedException;
/**
* Record Controller
*
......@@ -46,4 +48,27 @@ class RecordController extends \finc\Controller\RecordController
public const SUBITO_ARTICLE = "subito-article";
public const SUBITO_PARTIAL_COPY = "subito-partial-copy";
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
/* @var string */
protected $locale = 'en';
/* @var Client */
public static $instance;
/**
* Client constructor.
*
......@@ -119,6 +122,7 @@ class Client
$this->uriFactory = $uriFactory;
$this->streamFactory = $streamFactory;
$this->requestFactory = $requestFactory;
Client::$instance = $this;
}
/**
......@@ -502,6 +506,10 @@ class Client
$request = $this->buildRequest('get', "users/$userId");
$response = $this->sendAuthenticatedRequest($request);
if ($response->getStatusCode() === 401) {
throw new UserNotAuthorizedException();
}
if ($response->getStatusCode() !== 200) {
$this->throwException($response);
}
......@@ -852,6 +860,10 @@ class Client
$request = $this->buildRequest('post', 'logons', $body);
$response = $this->sendAuthenticatedRequest($request, false);
if ($response->getStatusCode() === 401) {
throw new UserNotAuthorizedException();
}
if ($response->getStatusCode() !== 201) {
$this->throwException($response);
}
......
......@@ -67,7 +67,8 @@ class Factory
return new GetIt(
$container->get('VuFind\Config')->get('getit'),
$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