|
@@ -22,14 +22,16 @@ class UserDeleteController
|
|
|
$body = json_decode((string)$request->getBody(), true) ?? [];
|
|
$body = json_decode((string)$request->getBody(), true) ?? [];
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- val::key('company_id', val::intType()->positive())
|
|
|
|
|
- ->key('user_id', val::intType()->positive())
|
|
|
|
|
|
|
+ val::key('user_id', val::intType()->positive())
|
|
|
->assert($body);
|
|
->assert($body);
|
|
|
} catch (ValidationException $e) {
|
|
} catch (ValidationException $e) {
|
|
|
return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
return ResponseLib::sendFail("Validation failed: " . $e->getFullMessage(), [], "E_VALIDATE")->withStatus(400);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $companyId = (int) $body['company_id'];
|
|
|
|
|
|
|
+ $companyId = (int)($request->getAttribute('api_company_id') ?? 0);
|
|
|
|
|
+ if ($companyId <= 0) {
|
|
|
|
|
+ return ResponseLib::sendFail('Authenticated company not found', [], 'E_VALIDATE')->withStatus(401);
|
|
|
|
|
+ }
|
|
|
$userId = (int) $body['user_id'];
|
|
$userId = (int) $body['user_id'];
|
|
|
|
|
|
|
|
$deleted = $this->model->deleteUserById($userId, $companyId);
|
|
$deleted = $this->model->deleteUserById($userId, $companyId);
|