diff --git a/deploy-to-apps.example.sh b/deploy-to-apps.example.sh index 23f32ff..4d7ce09 100644 --- a/deploy-to-apps.example.sh +++ b/deploy-to-apps.example.sh @@ -288,35 +288,42 @@ else exit 1 fi - # Handle existing unverified user (api_key will be null) - if [ "$EXISTING_USER" = "true" ]; then - echo "ℹ️ User already exists but not verified" - echo " User ID: $USER_ID" + # Check if API key is null (happens when email verification is enabled) + if [ "$SAAC_API_KEY" = "null" ] || [ -z "$SAAC_API_KEY" ]; then + # API key will be provided after email verification + if [ "$EXISTING_USER" = "true" ]; then + echo "ℹ️ User already exists but not verified" + echo " User ID: $USER_ID" - if [ "$VERIFICATION_SENT" = "true" ]; then - echo " ✅ New verification code sent!" - else - echo " ⚠️ Failed to send verification email" - fi - - # Load existing API key from config if it exists - if [ -f "$SAAC_CONFIG_FILE" ]; then - EXISTING_API_KEY=$(jq -r '.saac_api_key // ""' "$SAAC_CONFIG_FILE") - if [ -n "$EXISTING_API_KEY" ] && [ "$EXISTING_API_KEY" != "null" ]; then - SAAC_API_KEY="$EXISTING_API_KEY" - echo " 🔑 Using existing API key from config" + if [ "$VERIFICATION_SENT" = "true" ]; then + echo " ✅ New verification code sent!" + else + echo " ⚠️ Failed to send verification email" fi + + # Load existing API key from config if it exists + if [ -f "$SAAC_CONFIG_FILE" ]; then + EXISTING_API_KEY=$(jq -r '.saac_api_key // ""' "$SAAC_CONFIG_FILE") + if [ -n "$EXISTING_API_KEY" ] && [ "$EXISTING_API_KEY" != "null" ]; then + SAAC_API_KEY="$EXISTING_API_KEY" + echo " 🔑 Using existing API key from config" + fi + fi + else + # New user with email verification enabled + echo "✅ User registered!" + echo " User ID: $USER_ID" + echo " Email verification required" + echo "" + + # API key will be null - will get it after verification + SAAC_API_KEY="" fi else - # New user - api_key should be present - if [ "$SAAC_API_KEY" = "null" ] || [ -z "$SAAC_API_KEY" ]; then - echo "❌ Failed to extract API key from registration response" - echo "Response: $REGISTER_RESPONSE" - exit 1 - fi - + # API key provided - email verification disabled echo "✅ User registered!" echo " User ID: $USER_ID" + echo " 🔑 API key received" fi echo ""