service = $service; $this->user = $user; if ( !$this->user->isAdmin() && !$this->user->isRegular() && !$this->user->isPortal() ) { throw new Forbidden(); } } /** * @throws BadRequest * @throws Forbidden * @throws Error * @throws NotFound */ public function postActionSendCode(Request $request): bool { $data = $request->getParsedBody(); $id = $data->id ?? null; $phoneNumber = $data->phoneNumber ?? null; if (!$id) { throw new BadRequest("No 'id'."); } if (!$phoneNumber) { throw new BadRequest("No 'phoneNumber'."); } if (!$this->user->isAdmin() && $id !== $this->user->getId()) { throw new Forbidden(); } $this->service->sendCode($id, $phoneNumber); return true; } }