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; |
| 12 | use BO\Zmsentities\Scope; |
| 13 | use BO\Zmsentities\Useraccount; |
| 14 | use BO\Zmsentities\Exception\QuickLoginFailed; |
| 15 | use BO\Zmsclient\Exception; |
| 16 | use Psr\Http\Message\RequestInterface; |
| 17 | use Psr\Http\Message\ResponseInterface; |
| 18 | |
| 19 | class QuickLogin extends BaseController |
| 20 | { |
| 21 | /** |
| 22 | * @SuppressWarnings(Param) |
| 23 | */ |
| 24 | #[\Override] |
| 25 | public function readResponse( |
| 26 | RequestInterface $request, |
| 27 | ResponseInterface $response, |
| 28 | array $args |
| 29 | ): ResponseInterface { |
| 30 | $loginData = Helper\LoginForm::fromQuickLogin(); |
| 31 | if ($loginData->hasFailed()) { |
| 32 | throw new QuickLoginFailed(); |
| 33 | } |
| 34 | $loginData = $loginData->getStatus(); |
| 35 | $userAccount = new Useraccount(array( |
| 36 | 'id' => $loginData['loginName']['value'], |
| 37 | 'password' => $loginData['password']['value'] |
| 38 | )); |
| 39 | |
| 40 | try { |
| 41 | $workstation = \App::$http |
| 42 | ->readPostResult('/workstation/login/', $userAccount)->getEntity(); |
| 43 | } catch (Exception $exception) { |
| 44 | //ignore double login exception on quick login |
| 45 | if ($exception->template == 'BO\Zmsapi\Exception\Useraccount\UserAlreadyLoggedIn') { |
| 46 | $workstation = new Workstation($exception->data); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | \BO\Zmsclient\Auth::setKey($workstation->authkey, time() + \App::SESSION_DURATION); |
| 51 | $workstation->scope = new Scope(array('id' => $loginData['scope']['value'])); |
| 52 | $workstation->hint = $loginData['hint']['value']; |
| 53 | $workstation->name = $loginData['workstation']['value']; |
| 54 | \App::$http->readPostResult('/workstation/', $workstation)->getEntity(); |
| 55 | $basePath = $request->getBasePath(); |
| 56 | |
| 57 | return $response->withRedirect($basePath . '/' . trim($loginData['redirectUrl']['value'], "/")); |
| 58 | } |
| 59 | } |