Lines
0.00%
0 / 24
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| QuickLogin | 0.00% | 0 / 24 | 0.00% | 0 / 1 | 20 | 0.00% | 0 / 1 | |||
| readResponse | 0.00% | 0 / 24 | 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 | $workstation = null; | |
| 41 | try { | |
| 42 | /** @var mixed $workstation */ | |
| 43 | $workstation = \App::http() | |
| 44 | ->readPostResult('/workstation/login/', $userAccount)->getEntity(); | |
| 45 | } catch (Exception $exception) { | |
| 46 | //ignore double login exception on quick login | |
| 47 | if ($exception->template == 'BO\Zmsbackend\Useraccount\Exception\UserAlreadyLoggedIn') { | |
| 48 | $workstation = new Workstation($exception->data); | |
| 49 | } else { | |
| 50 | throw $exception; | |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | /** @var mixed $workstation */ | |
| 55 | $workstation = $workstation; | |
| 56 | /** @var mixed $authkey */ | |
| 57 | $authkey = $workstation->authkey; | |
| 58 | \BO\Zmsclient\Auth::setKey($authkey, time() + \App::SESSION_DURATION); | |
| 59 | $workstation->scope = new Scope(array('id' => $loginData['scope']['value'])); | |
| 60 | $workstation->hint = $loginData['hint']['value']; | |
| 61 | $workstation->name = $loginData['workstation']['value']; | |
| 62 | \App::http()->readPostResult('/workstation/', $workstation)->getEntity(); | |
| 63 | /** @var mixed $request */ | |
| 64 | $basePath = $request->getBasePath(); | |
| 65 | ||
| 66 | /** @var \BO\Slim\Response $response */ | |
| 67 | return $response->withRedirect($basePath . '/' . trim($loginData['redirectUrl']['value'], "/")); | |
| 68 | } | |
| 69 | } |