prod fixes

This commit is contained in:
2026-04-01 21:31:19 -04:00
parent f6f02f7698
commit e17b3bd86c
6 changed files with 34 additions and 12 deletions

View File

@@ -107,8 +107,13 @@ if [[ "$ENV" == "dev" ]]; then
else
# Prod: prompt for credentials
read -p "Admin email: " USER_EMAIL
read -s -p "Admin password (min 8 chars): " USER_PASSWORD
read -rs -p "Admin password (min 8 chars): " USER_PASSWORD
echo ""
echo -e "${BLUE}Password captured: ${#USER_PASSWORD} characters${NC}"
if [[ ${#USER_PASSWORD} -lt 8 ]]; then
echo -e "${RED}✗ Password must be at least 8 characters${NC}"
exit 1
fi
read -p "Admin display name: " USER_NAME
read -p "License type [free|pro|enterprise] (default: pro): " LICENSE_TYPE
LICENSE_TYPE="${LICENSE_TYPE:-pro}"
@@ -131,18 +136,35 @@ else
sleep 3
echo -e "${GREEN}→${NC} Registering user via API..."
PAYLOAD=$(jq -n \
--arg email "$USER_EMAIL" \
--arg password "$USER_PASSWORD" \
--arg name "$USER_NAME" \
'{email: $email, password: $password, name: $name}')
HTTP_CODE=$(curl -s -o /tmp/dexorder-init-response.json -w "%{http_code}" \
-X POST "$BASE_URL/api/auth/register" \
-H "Content-Type: application/json" \
-d "{\"email\":\"$USER_EMAIL\",\"password\":\"$USER_PASSWORD\",\"name\":\"$USER_NAME\"}")
-d "$PAYLOAD")
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "201" ]]; then
echo -e "${GREEN}✓ User registered via API${NC}"
elif [[ "$HTTP_CODE" == "400" ]]; then
echo -e "${YELLOW}⚠️ API returned 400 (user may already exist), continuing...${NC}"
RESPONSE=$(cat /tmp/dexorder-init-response.json 2>/dev/null)
# Check if this is a "user already exists" 400 vs a validation error
if echo "$RESPONSE" | grep -qi "already exist\|user already\|duplicate"; then
echo -e "${YELLOW}⚠️ User already exists, continuing...${NC}"
else
echo -e "${RED}✗ Registration failed (400):${NC}"
echo "$RESPONSE"
rm -f /tmp/dexorder-init-response.json
exit 1
fi
else
echo -e "${YELLOW}⚠️ API returned HTTP $HTTP_CODE${NC}"
echo -e "${RED}✗ API returned HTTP $HTTP_CODE${NC}"
cat /tmp/dexorder-init-response.json 2>/dev/null || true
rm -f /tmp/dexorder-init-response.json
exit 1
fi
rm -f /tmp/dexorder-init-response.json