/** * @brief Delete a Mozilla Sync user. * * DELETE https://server/pathname/version/username * * Deletes the user account. * NOTE: Requires simple authentication with the username and password associated with the account. * * Return value: * 0 on success * * Possible errors: * 503: there was an error removing the user * 404: the user does not exist in the database * 401: authentication failed * * @param string $syncHash Mozilla Sync user hash of the user to be deleted. */ private function deleteUser($syncHash) { if (User::isAutoCreateUser()) { //auto create accounts only Utils::changeHttpStatus(Utils::STATUS_INVALID_USER); Utils::writeLog("Failed to delete user " . $syncHash . ". Delete disabled"); } if (User::syncUserExists($syncHash) === false) { Utils::changeHttpStatus(Utils::STATUS_NOT_FOUND); Utils::writeLog("Failed to delete user " . $syncHash . ". User does not exist."); } if (User::authenticateUser($syncHash) === false) { Utils::changeHttpStatus(Utils::STATUS_INVALID_USER); Utils::writeLog("Authentication for deleting user " . $syncHash . " failed."); } $syncId = User::syncHashToSyncId($syncHash); if ($syncId === false) { Utils::changeHttpStatus(Utils::STATUS_INVALID_USER); Utils::writeLog("Failed to convert user " . $syncHash . " to Sync ID."); } if (Storage::deleteStorage($syncId) === false) { Utils::changeHttpStatus(Utils::STATUS_MAINTENANCE); Utils::writeLog("Failed to delete storage for user " . $syncId . "."); } if (User::deleteUser($syncId) === false) { Utils::changeHttpStatus(Utils::STATUS_MAINTENANCE); Utils::writeLog("Failed to delete user " . $syncId . "."); } OutputData::write('0'); }
/** * @brief Detete user * * DELETE https://server/pathname/version/username * * Deletes the user account. * NOTE: Requires simple authentication with the username and password associated with the account. * * Return value: * 0 on success * * Possible errors: * 503: there was an error removing the user * 404: the user does not exist in the database * 401: authentication failed * * @param string $userName */ private function deleteUser($syncUserHash) { if (User::syncUserExists($syncUserHash) == false) { Utils::changeHttpStatus(Utils::STATUS_NOT_FOUND); return true; } if (User::authenticateUser($syncUserHash) == false) { Utils::changeHttpStatus(Utils::STATUS_INVALID_USER); return true; } $userId = User::userHashToId($syncUserHash); if ($userId == false) { Utils::changeHttpStatus(Utils::STATUS_INVALID_USER); return true; } if (Storage::deleteStorage($userId) == false) { Utils::changeHttpStatus(Utils::STATUS_MAINTENANCE); return true; } if (User::deleteUser($userId) == false) { Utils::changeHttpStatus(Utils::STATUS_MAINTENANCE); return true; } OutputData::write('0'); return true; }