chore: snapshot before development sync
This commit is contained in:
@@ -138,43 +138,10 @@ hub_mode_init() {
|
||||
done
|
||||
echo -e "${GREEN}✓ Hub disponible${NC}"
|
||||
|
||||
# ── 2. Registrar usuario via Hub ───────────────────────────────────────────
|
||||
echo -e "\n${YELLOW}[2/4] Registrando usuario '${USER_USERNAME}' en tenant '${TENANT_SLUG}'...${NC}"
|
||||
echo -e "${YELLOW} (Si el tenant no existe en el Hub, el registro fallará aquí)${NC}"
|
||||
|
||||
local register_response http_code
|
||||
register_response=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
"${HUB_URL}/api/v1/auth/register" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"username\": \"${USER_USERNAME}\",
|
||||
\"email\": \"${USER_EMAIL}\",
|
||||
\"password\": \"${USER_PASSWORD}\",
|
||||
\"first_name\": \"${USER_FIRSTNAME}\",
|
||||
\"last_name\": \"${USER_LASTNAME}\",
|
||||
\"tenant_slug\":\"${TENANT_SLUG}\"
|
||||
}")
|
||||
|
||||
http_code=$(echo "${register_response}" | tail -n1)
|
||||
local register_body
|
||||
register_body=$(echo "${register_response}" | head -n -1)
|
||||
|
||||
if [[ "${http_code}" == "201" ]]; then
|
||||
echo -e "${GREEN}✓ Usuario creado exitosamente${NC}"
|
||||
elif [[ "${http_code}" == "409" ]] || (echo "${register_body}" | grep -qi "already\|existe\|conflict" 2>/dev/null); then
|
||||
echo -e "${YELLOW}⚠ Usuario ya existe, continuando con login...${NC}"
|
||||
else
|
||||
echo -e "${RED}✗ Error registrando usuario (HTTP ${http_code}):${NC}"
|
||||
echo "${register_body}" | python3 -m json.tool 2>/dev/null || echo "${register_body}"
|
||||
echo ""
|
||||
echo -e "${YELLOW} Asegúrate de que el tenant '${TENANT_SLUG}' esté provisionado en el Hub.${NC}"
|
||||
echo -e " Un administrador del Hub debe ejecutar:${NC}"
|
||||
echo -e " curl -X POST ${HUB_URL}/api/v1/hub/provisioning/ \\"
|
||||
echo -e " -H 'Authorization: Bearer <hub-admin-token>' \\"
|
||||
echo -e " -H 'Content-Type: application/json' \\"
|
||||
echo -e " -d '{\"name\":\"${COMPANY_NAME}\",\"slug\":\"${TENANT_SLUG}\",\"contact_email\":\"${USER_EMAIL}\",\"plan\":\"ENTERPRISE\",\"license_months\":12}'"
|
||||
exit 1
|
||||
fi
|
||||
# ── 2. Verificar que el usuario exista (creado desde el Hub) ─────────────
|
||||
echo -e "\n${YELLOW}[2/4] El usuario debe estar creado previamente desde el Hub.${NC}"
|
||||
echo -e "${YELLOW} El registro requiere un token de invitación gestionado por el Hub.${NC}"
|
||||
echo -e "${CYAN} Usuario esperado: ${USER_USERNAME} / tenant: ${TENANT_SLUG}${NC}"
|
||||
|
||||
# ── 3. Login para obtener token y crear empresa ────────────────────────────
|
||||
echo -e "\n${YELLOW}[3/4] Login y creación de empresa en Anexo76...${NC}"
|
||||
|
||||
Reference in New Issue
Block a user