Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Logout
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsadmin;
9
10use BO\Zmsclient\Auth;
11use App;
12
13class 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}