Fix script to handle new user with email verification
Problem: New users with email verification enabled receive api_key: null, but script only checked for existing_user flag, not null API key. Solution: Check if api_key is null first, then determine if it's: - Existing unverified user (load key from config) - New user with verification (api_key comes after verification) - New user without verification (api_key provided immediately) This fixes the 'Failed to extract API key' error for new registrations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -288,7 +288,9 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Handle existing unverified user (api_key will be null)
|
||||
# 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"
|
||||
@@ -308,15 +310,20 @@ else
|
||||
fi
|
||||
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
|
||||
|
||||
# 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
|
||||
# API key provided - email verification disabled
|
||||
echo "✅ User registered!"
|
||||
echo " User ID: $USER_ID"
|
||||
echo " 🔑 API key received"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user