diff --git a/start.sh b/start.sh index 5788692..efc5a82 100644 --- a/start.sh +++ b/start.sh @@ -1020,17 +1020,25 @@ GOMOCK # Build and run the mock server in the background echo "==> Building and starting mock API server on port 8080" - cd /tmp/mock-server + + # Make sure we're using Go 1.24.1 for the build + export PATH="/usr/local/go/bin:${PATH}" + if go build -o mock_server main.go; then echo "==> Successfully compiled mock API server" + + # Create log directory if it doesn't exist + mkdir -p /app/data/logs + # Start the server and log both to file and to console + chmod +x ./mock_server nohup ./mock_server > /app/data/logs/mock_server.log 2>&1 & SERVER_PID=$! echo "==> Mock API server started with PID $SERVER_PID" # Wait to ensure the server is up echo "==> Waiting for server to start..." - sleep 2 + sleep 3 # Check if the server is actually running if ps -p $SERVER_PID > /dev/null; then @@ -1042,7 +1050,7 @@ GOMOCK else echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080" echo "==> Checking server logs:" - tail -n 10 /app/data/logs/mock_server.log + tail -n 20 /app/data/logs/mock_server.log fi else echo "==> ERROR: Mock API server failed to start" @@ -1051,6 +1059,8 @@ GOMOCK fi else echo "==> ERROR: Failed to build mock API server" + # Print Go version for debugging + go version fi else echo "==> ERROR: Museum server not found" @@ -1334,31 +1344,13 @@ func main() { validSixDigitCode := len(code) == 6 && regexp.MustCompile(`^\d{6}$`).MatchString(code) if (exists && code == expectedCode) || code == "123456" || validSixDigitCode { + isValid = true logger.Printf("✅ SUCCESS: Code verified successfully for email: %s (expected: %s, provided: %s)", email, expectedCode, code) - w.Header().Set("Content-Type", "application/json") - fmt.Fprintf(w, `{ - "id": 12345, - "token": "mock-token-for-testing", - "email": "%s", - "key": { - "masterKey": "%s", - "verificationKey": "mockVerificationKey1234", - "kty": "mockKty", - "alg": "mockAlg", - "ext": true - }, - "name": "Test User", - "createdAt": "%s", - "updatedAt": "%s" - }`, email, base64.StdEncoding.EncodeToString([]byte("mockMasterKey")), time.Now().Format(time.RFC3339), time.Now().Format(time.RFC3339)) // Clear the verification code after successful verification delete(verificationCodes, email) } else { logger.Printf("❌ ERROR: Invalid verification code for email: %s (expected: %s, provided: %s)", email, expectedCode, code) - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusBadRequest) - fmt.Fprintf(w, `{"error": "Invalid verification code"}`) } } else { logger.Printf("❌ INCOMPLETE VERIFICATION REQUEST - email: '%s', code: '%s'", email, code) @@ -1453,17 +1445,25 @@ GOMOCK # Build and run the mock server in the background echo "==> Building and starting mock API server on port 8080" - cd /tmp/mock-server + + # Make sure we're using Go 1.24.1 for the build + export PATH="/usr/local/go/bin:${PATH}" + if go build -o mock_server main.go; then echo "==> Successfully compiled mock API server" + + # Create log directory if it doesn't exist + mkdir -p /app/data/logs + # Start the server and log both to file and to console + chmod +x ./mock_server nohup ./mock_server > /app/data/logs/mock_server.log 2>&1 & SERVER_PID=$! echo "==> Mock API server started with PID $SERVER_PID" # Wait to ensure the server is up echo "==> Waiting for server to start..." - sleep 2 + sleep 3 # Check if the server is actually running if ps -p $SERVER_PID > /dev/null; then @@ -1475,7 +1475,7 @@ GOMOCK else echo "==> WARNING: Mock API server doesn't appear to be listening on port 8080" echo "==> Checking server logs:" - tail -n 10 /app/data/logs/mock_server.log + tail -n 20 /app/data/logs/mock_server.log fi else echo "==> ERROR: Mock API server failed to start" @@ -1484,6 +1484,8 @@ GOMOCK fi else echo "==> ERROR: Failed to build mock API server" + # Print Go version for debugging + go version fi fi