Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| UseraccountDelete | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @package Zmsadmin |
| 6 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | namespace BO\Zmsadmin; |
| 11 | |
| 12 | use BO\Mellon\Validator; |
| 13 | use BO\Slim\Render; |
| 14 | use BO\Zmsentities\Exception\UserAccountMissingRights; |
| 15 | |
| 16 | /** |
| 17 | * Delete an Useraccount |
| 18 | */ |
| 19 | class UseraccountDelete extends BaseController |
| 20 | { |
| 21 | /** |
| 22 | * |
| 23 | * @return \Psr\Http\Message\ResponseInterface |
| 24 | */ |
| 25 | #[\Override] |
| 26 | public function readResponse( |
| 27 | \Psr\Http\Message\RequestInterface $request, |
| 28 | \Psr\Http\Message\ResponseInterface $response, |
| 29 | array $args |
| 30 | ): \Psr\Http\Message\ResponseInterface { |
| 31 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); |
| 32 | if (! $workstation->getUseraccount()->hasPermissions(['useraccount'])) { |
| 33 | throw new UserAccountMissingRights(); |
| 34 | } |
| 35 | |
| 36 | $loginName = Validator::value($args['loginname'])->isString()->getValue(); |
| 37 | \App::$http->readDeleteResult('/useraccount/' . $loginName . '/')->getEntity(); |
| 38 | return Render::redirect( |
| 39 | 'useraccountList', |
| 40 | array(), |
| 41 | array( |
| 42 | 'success' => 'useraccount_deleted' |
| 43 | ) |
| 44 | ); |
| 45 | } |
| 46 | } |