Lines
100.00%
22 / 22
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Logout | 100.00% | 22 / 22 | 100.00% | 1 / 1 | 3 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 22 / 22 | 100.00% | 1 / 1 | 3 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsadmin | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsadmin; | |
| 9 | ||
| 10 | use BO\Zmsclient\Auth; | |
| 11 | use App; | |
| 12 | ||
| 13 | class Logout extends BaseController | |
| 14 | { | |
| 15 | /** | |
| 16 | * @SuppressWarnings(Param) | |
| 17 | * @return \Psr\Http\Message\ResponseInterface | |
| 18 | */ | |
| 19 | #[\Override] | |
| 20 | public function readResponse( | |
| 21 | \Psr\Http\Message\RequestInterface $request, | |
| 22 | \Psr\Http\Message\ResponseInterface $response, | |
| 23 | array $args | |
| 24 | ): \Psr\Http\Message\ResponseInterface { | |
| 25 | try { | |
| 26 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 0])->getEntity(); | |
| 27 | \App::$http->readDeleteResult('/workstation/login/' . $workstation->useraccount['id'] . '/')->getEntity(); | |
| 28 | } catch (\BO\Zmsclient\Exception $exception) { | |
| 29 | if ("BO\Zmsentities\Exception\UseraccountMissingLogin" !== $exception->template) { | |
| 30 | throw $exception; | |
| 31 | } | |
| 32 | } | |
| 33 | $sessionHash = hash('sha256', \BO\Zmsclient\Auth::getKey()); | |
| 34 | App::$log->info('User logged out', [ | |
| 35 | 'event' => 'auth_logout', | |
| 36 | 'timestamp' => date('c'), | |
| 37 | 'username' => $workstation->useraccount['id'], | |
| 38 | 'hashed_session_token' => $sessionHash, | |
| 39 | 'logout_type' => 'manual', | |
| 40 | 'application' => 'zmsadmin' | |
| 41 | ]); | |
| 42 | \BO\Zmsclient\Auth::removeKey(); | |
| 43 | return \BO\Slim\Render::withHtml( | |
| 44 | $response, | |
| 45 | 'page/logout.twig', | |
| 46 | array( | |
| 47 | 'title' => 'Erfolgreich abgemeldet' | |
| 48 | ) | |
| 49 | ); | |
| 50 | } | |
| 51 | } |