Update script for new API response format
API changes: - 'verified' renamed to 'email_verified' - 'api_key' field removed when null (not included in response) Script changes: - Check 'email_verified' field instead of 'verified' - Handle missing 'api_key' field (use jq default: '.api_key // ""') - Check email_verified AND api_key presence to determine flow - Display email verification status clearly 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -278,7 +278,8 @@ else
|
|||||||
|
|
||||||
# Extract user data
|
# Extract user data
|
||||||
USER_ID=$(echo "$REGISTER_RESPONSE" | jq -r '.user_id')
|
USER_ID=$(echo "$REGISTER_RESPONSE" | jq -r '.user_id')
|
||||||
SAAC_API_KEY=$(echo "$REGISTER_RESPONSE" | jq -r '.api_key')
|
EMAIL_VERIFIED=$(echo "$REGISTER_RESPONSE" | jq -r '.email_verified // false')
|
||||||
|
SAAC_API_KEY=$(echo "$REGISTER_RESPONSE" | jq -r '.api_key // ""')
|
||||||
EXISTING_USER=$(echo "$REGISTER_RESPONSE" | jq -r '.existing_user // false')
|
EXISTING_USER=$(echo "$REGISTER_RESPONSE" | jq -r '.existing_user // false')
|
||||||
VERIFICATION_SENT=$(echo "$REGISTER_RESPONSE" | jq -r '.verification_code_sent // false')
|
VERIFICATION_SENT=$(echo "$REGISTER_RESPONSE" | jq -r '.verification_code_sent // false')
|
||||||
|
|
||||||
@@ -288,9 +289,15 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if API key is null (happens when email verification is enabled)
|
# Check if user is verified and has API key
|
||||||
if [ "$SAAC_API_KEY" = "null" ] || [ -z "$SAAC_API_KEY" ]; then
|
if [ "$EMAIL_VERIFIED" = "true" ] && [ -n "$SAAC_API_KEY" ] && [ "$SAAC_API_KEY" != "null" ]; then
|
||||||
# API key will be provided after email verification
|
# Email verification disabled OR user already verified - API key provided
|
||||||
|
echo "✅ User registered!"
|
||||||
|
echo " User ID: $USER_ID"
|
||||||
|
echo " 🔑 API key received"
|
||||||
|
echo " Email verified: true"
|
||||||
|
else
|
||||||
|
# Email verification required
|
||||||
if [ "$EXISTING_USER" = "true" ]; then
|
if [ "$EXISTING_USER" = "true" ]; then
|
||||||
echo "ℹ️ User already exists but not verified"
|
echo "ℹ️ User already exists but not verified"
|
||||||
echo " User ID: $USER_ID"
|
echo " User ID: $USER_ID"
|
||||||
@@ -303,7 +310,7 @@ else
|
|||||||
|
|
||||||
# Load existing API key from config if it exists
|
# Load existing API key from config if it exists
|
||||||
if [ -f "$SAAC_CONFIG_FILE" ]; then
|
if [ -f "$SAAC_CONFIG_FILE" ]; then
|
||||||
EXISTING_API_KEY=$(jq -r '.saac_api_key // ""' "$SAAC_CONFIG_FILE")
|
EXISTING_API_KEY=$(jq -r '.user.api_key // ""' "$SAAC_CONFIG_FILE")
|
||||||
if [ -n "$EXISTING_API_KEY" ] && [ "$EXISTING_API_KEY" != "null" ]; then
|
if [ -n "$EXISTING_API_KEY" ] && [ "$EXISTING_API_KEY" != "null" ]; then
|
||||||
SAAC_API_KEY="$EXISTING_API_KEY"
|
SAAC_API_KEY="$EXISTING_API_KEY"
|
||||||
echo " 🔑 Using existing API key from config"
|
echo " 🔑 Using existing API key from config"
|
||||||
@@ -313,17 +320,13 @@ else
|
|||||||
# New user with email verification enabled
|
# New user with email verification enabled
|
||||||
echo "✅ User registered!"
|
echo "✅ User registered!"
|
||||||
echo " User ID: $USER_ID"
|
echo " User ID: $USER_ID"
|
||||||
echo " Email verification required"
|
echo " Email verified: false"
|
||||||
|
echo " Verification code sent: $VERIFICATION_SENT"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# API key will be null - will get it after verification
|
# No API key yet - will get after verification
|
||||||
SAAC_API_KEY=""
|
SAAC_API_KEY=""
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
# API key provided - email verification disabled
|
|
||||||
echo "✅ User registered!"
|
|
||||||
echo " User ID: $USER_ID"
|
|
||||||
echo " 🔑 API key received"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user