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