response->getStatus() !== ServerStatus::OK) { return; } $json = json_decode($this->requestBody); try { $user = new User(); $user->setUsername($json->username); $user->setPassword(Password::GetHash($json->password)); $user->setEmail($json->email); $user->setJabberAddress($json->jabberAddress); $user->Save(); $this->response = new ApiJsonResponse(); $this->response->setParameter('userId', $user->getUserId()); } catch (DatabaseException $e) { $this->response = new ApiJsonResponse(); $this->response->setParameter('success', false); $this->response->setMessage($e->getMessage()); switch ($e->getCode()) { case DatabaseException::CONNECTION_FAILED: $this->response->setStatus(ServerStatus::INTERNAL_ERROR); break; default: $this->response->setStatus(ServerStatus::INTERNAL_ERROR); } } catch (Throwable $e) { $this->response = new ApiJsonResponse(ServerStatus::BAD_REQUEST); $this->response->setParameter('success', false); $this->response->setMessage($e->getMessage()); } } }