Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| WorkstationPassword | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package ZMS API |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsapi; |
| 9 | |
| 10 | use BO\Slim\Render; |
| 11 | use BO\Mellon\Validator; |
| 12 | use BO\Zmsdb\Useraccount as Query; |
| 13 | |
| 14 | class WorkstationPassword extends BaseController |
| 15 | { |
| 16 | /** |
| 17 | * @SuppressWarnings(Param) |
| 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 | $workstation = (new Helper\User($request, 3))->checkRights(); |
| 26 | $useraccount = $workstation->getUseraccount(); |
| 27 | $input = Validator::input()->isJson()->assertValid()->getValue(); |
| 28 | $entity = new \BO\Zmsentities\Useraccount($input); |
| 29 | $entity->testValid(); |
| 30 | if (isset($input['email'])) { |
| 31 | $useraccount->email = $input['email']; |
| 32 | } |
| 33 | Helper\UserAuth::testPasswordMatching($useraccount, $input['password']); |
| 34 | if (isset($input['changePassword'])) { |
| 35 | $useraccount->password = $useraccount->getHash(reset($input['changePassword'])); |
| 36 | } |
| 37 | |
| 38 | $message = Response\Message::create($request); |
| 39 | $message->data = (new Query())->writeUpdatedEntity($useraccount->getId(), $useraccount); |
| 40 | |
| 41 | $response = Render::withLastModified($response, time(), '0'); |
| 42 | $response = Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); |
| 43 | return $response; |
| 44 | } |
| 45 | } |