From bc2190dae3dc799e2b8124395b968d1b64962c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20West=C3=B6=C3=B6?= Date: Sun, 25 Jan 2026 00:29:34 +0100 Subject: [PATCH] Update script for new API response format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- deploy-to-apps.example.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/deploy-to-apps.example.sh b/deploy-to-apps.example.sh index f33e1b8..374d391 100644 --- a/deploy-to-apps.example.sh +++ b/deploy-to-apps.example.sh @@ -278,7 +278,8 @@ else # Extract user data 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') VERIFICATION_SENT=$(echo "$REGISTER_RESPONSE" | jq -r '.verification_code_sent // false') @@ -288,9 +289,15 @@ else exit 1 fi - # 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 + # Check if user is verified and has API key + if [ "$EMAIL_VERIFIED" = "true" ] && [ -n "$SAAC_API_KEY" ] && [ "$SAAC_API_KEY" != "null" ]; then + # 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 echo "â„šī¸ User already exists but not verified" echo " User ID: $USER_ID" @@ -303,7 +310,7 @@ else # 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") + EXISTING_API_KEY=$(jq -r '.user.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" @@ -313,17 +320,13 @@ else # New user with email verification enabled echo "✅ User registered!" echo " User ID: $USER_ID" - echo " Email verification required" + echo " Email verified: false" + echo " Verification code sent: $VERIFICATION_SENT" echo "" - # API key will be null - will get it after verification + # No API key yet - will get 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 ""