Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
QuickLogin | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
readResponse | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
20 |
1 | <?php |
2 | |
3 | /** |
4 | * @package Zmsstatistic |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsstatistic; |
9 | |
10 | use BO\Mellon\Validator; |
11 | use BO\Zmsentities\Workstation as Entity; |
12 | |
13 | class QuickLogin extends BaseController |
14 | { |
15 | /** |
16 | * @SuppressWarnings(Param) |
17 | * @param \Psr\Http\Message\RequestInterface|\BO\Slim\Request $request |
18 | * @return String |
19 | */ |
20 | public function readResponse( |
21 | \Psr\Http\Message\RequestInterface $request, |
22 | \Psr\Http\Message\ResponseInterface $response, |
23 | array $args |
24 | ) { |
25 | $loginData = Helper\LoginForm::fromQuickLogin(); |
26 | if ($loginData->hasFailed()) { |
27 | throw new \BO\Zmsentities\Exception\QuickLoginFailed(); |
28 | } |
29 | $loginData = $loginData->getStatus(); |
30 | $userAccount = new \BO\Zmsentities\Useraccount(array( |
31 | 'id' => $loginData['loginName']['value'], |
32 | 'password' => $loginData['password']['value'] |
33 | )); |
34 | |
35 | try { |
36 | $workstation = \App::$http |
37 | ->readPostResult('/workstation/login/', $userAccount)->getEntity(); |
38 | } catch (\BO\Zmsclient\Exception $exception) { |
39 | //ignore double login exception on quick login |
40 | if ($exception->template == 'BO\Zmsapi\Exception\Useraccount\UserAlreadyLoggedIn') { |
41 | $workstation = new Entity($exception->data); |
42 | } |
43 | } |
44 | |
45 | \BO\Zmsclient\Auth::setKey($workstation->authkey, time() + \App::SESSION_DURATION); |
46 | $workstation->scope = new \BO\Zmsentities\Scope(array('id' => $loginData['scope']['value'])); |
47 | $workstation->hint = $loginData['hint']['value']; |
48 | $workstation->name = $loginData['workstation']['value']; |
49 | $workstation = \App::$http->readPostResult('/workstation/', $workstation)->getEntity(); |
50 | $basePath = $request->getBasePath(); |
51 | |
52 | return $response->withRedirect($basePath . '/' . trim($loginData['redirectUrl']['value'], "/")); |
53 | } |
54 | } |