34 lines
1.2 KiB
Bash
Executable File
34 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "🔍 检查 test@example.com 的家族树"
|
|
echo "=================================="
|
|
echo ""
|
|
|
|
BASE_URL="http://localhost:3000"
|
|
TEST_EMAIL="test@example.com"
|
|
TEST_PASSWORD="password123"
|
|
|
|
# 1. 获取 CSRF token
|
|
CSRF_RESPONSE=$(curl -s -c cookies.txt -b cookies.txt "$BASE_URL/api/auth/csrf")
|
|
CSRF_TOKEN=$(echo $CSRF_RESPONSE | grep -o '"csrfToken":"[^"]*"' | cut -d'"' -f4)
|
|
|
|
# 2. 登录
|
|
curl -s -c cookies.txt -b cookies.txt -X POST "$BASE_URL/api/auth/callback/credentials" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"email\":\"$TEST_EMAIL\",\"password\":\"$TEST_PASSWORD\",\"csrfToken\":\"$CSRF_TOKEN\",\"callbackUrl\":\"$BASE_URL\",\"json\":true}" > /dev/null
|
|
|
|
# 3. 获取用户资料
|
|
echo "📊 用户资料:"
|
|
curl -s -b cookies.txt "$BASE_URL/api/user/profile" | python3 -c "import sys, json; print(json.dumps(json.load(sys.stdin), indent=2, ensure_ascii=False))"
|
|
echo ""
|
|
|
|
# 4. 获取家族树列表
|
|
echo "🌳 家族树列表:"
|
|
curl -s -b cookies.txt "$BASE_URL/api/trees" | python3 -c "import sys, json; data=json.load(sys.stdin); print(f'共 {len(data[\"trees\"])} 个家族树:'); [print(f' - {t[\"name\"]}') for t in data['trees']]"
|
|
echo ""
|
|
|
|
# 清理
|
|
rm -f cookies.txt
|
|
|
|
echo "✅ 检查完成"
|