Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| 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 String |
| 18 | */ |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ) { |
| 24 | try { |
| 25 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 0])->getEntity(); |
| 26 | \App::$http->readDeleteResult('/workstation/login/' . $workstation->useraccount['id'] . '/')->getEntity(); |
| 27 | } catch (\BO\Zmsclient\Exception $exception) { |
| 28 | if ("BO\Zmsentities\Exception\UseraccountMissingLogin" !== $exception->template) { |
| 29 | throw $exception; |
| 30 | } |
| 31 | } |
| 32 | $sessionHash = hash('sha256', \BO\Zmsclient\Auth::getKey()); |
| 33 | App::$log->info('User logged out', [ |
| 34 | 'event' => 'auth_logout', |
| 35 | 'timestamp' => date('c'), |
| 36 | 'username' => $workstation->useraccount['id'], |
| 37 | 'hashed_session_token' => $sessionHash, |
| 38 | 'logout_type' => 'manual', |
| 39 | 'application' => 'zmsadmin' |
| 40 | ]); |
| 41 | \BO\Zmsclient\Auth::removeKey(); |
| 42 | return \BO\Slim\Render::withHtml( |
| 43 | $response, |
| 44 | 'page/logout.twig', |
| 45 | array( |
| 46 | 'title' => 'Erfolgreich abgemeldet' |
| 47 | ) |
| 48 | ); |
| 49 | } |
| 50 | } |