Skip to content
Snippets Groups Projects
Commit 1a45b3c5 authored by Alexander Purr's avatar Alexander Purr Committed by Dorian Merz
Browse files

refs #18173 [fid] add reload of user details after ordering (pda, subito)

* using reload flag within user details request to force refresh
* do not save order list in session any more
parent 6c155ce9
No related merge requests found
......@@ -108,6 +108,7 @@ trait FidAcquisitionTrait
$hydratorData += $this->addTypeSpecificOrderInformation($form);
$form->getHydrator()->hydrate($hydratorData, $order = new Order());
$this->client->requestOrderCreation($order);
$this->client->requestUserDetails(null, true);
$message = $this->translate('fid::acquisition_success');
$messenger = $this->flashMessenger();
$messenger->addSuccessMessage($message);
......
......@@ -18,7 +18,6 @@
* @author Sebastian Kehr <kehr@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
*/
namespace fid\Service;
use fid\Service\DataTransferObject\Library;
......@@ -57,7 +56,6 @@ class Client
*/
protected $session;
/**
* @var CookieManager
*/
......@@ -251,10 +249,6 @@ class Client
*/
public function requestOrderList(): array
{
if ($list = $this->session['orders'] ?? null) {
return $list;
}
$request = $this->buildRequest('get', 'orders');
$response = $this->sendAuthenticatedRequest($request);
......@@ -269,8 +263,7 @@ class Client
return $order->getId();
}, $list);
return $this->session['orders'] = array_combine($keys, $list);
return array_combine($keys, $list);
}
/**
......@@ -337,7 +330,7 @@ class Client
* @throws ClientException
* @throws UserNotAuthorizedException
*/
public function requestUserDetails($userId = null): ?User
public function requestUserDetails($userId = null, $forceRelaod = false): ?User
{
$logon = $this->restoreLogon();
......@@ -345,9 +338,11 @@ class Client
$user = $this->session['user'] ?? null;
$ownId = $logon->getOwnerId();
if (is_null($userId) || $userId === $ownId) {
if (null === $userId || $userId === $ownId) {
// user asks for own profile data
if (!empty($user)) return $user;
if (!empty($user) && !$forceRelaod) {
return $user;
}
$userId = $ownId;
} else {
// user asks for another user's profile
......@@ -365,8 +360,10 @@ class Client
$user = $this->serializer->deserialize((string)$response->getBody(),
User::class, 'json', ['groups' => ['user:details:response']]);
if ($ownId === $userId) $this->session['user'] = $user;
return $user;
if ($ownId === $userId) {
$this->session['user'] = $user;
}
return $user;
}
/**
......@@ -462,7 +459,8 @@ class Client
return $this->session['users'] = array_combine($keys, $list);
}
public function flushUserList() {
public function flushUserList()
{
unset($this->session['users']);
}
......@@ -499,14 +497,14 @@ class Client
* @return bool
* @throws ClientException
*/
public function isAuthorized(String $permission) {
public function isAuthorized(String $permission)
{
try {
$this->authorize($permission);
} catch (UserAuthorizationException $exception) {
return FALSE;
return false;
}
return TRUE;
return true;
}
/**
......@@ -602,7 +600,6 @@ class Client
return $result;
}
/**
* @return Logon
* @throws ClientException
......@@ -733,7 +730,6 @@ class Client
$this->session->exchangeArray(compact('logon'));
$logon->setToken($token);
return $logon;
}
protected function parseLogon(string $logon): Logon
......
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