59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Permission Verification Script
|
|
# Quickly check if all permissions are working correctly
|
|
|
|
DIRECTUS_URL="http://localhost:8055"
|
|
ADMIN_EMAIL="admin@assetmanagement.com"
|
|
ADMIN_PASSWORD="AssetAdmin2024!"
|
|
|
|
echo "🔍 Verifying Directus Permissions..."
|
|
echo
|
|
|
|
# Authenticate
|
|
AUTH_RESPONSE=$(curl -s -X POST "$DIRECTUS_URL/auth/login" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"email\":\"$ADMIN_EMAIL\",\"password\":\"$ADMIN_PASSWORD\"}")
|
|
|
|
ACCESS_TOKEN=$(echo $AUTH_RESPONSE | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)
|
|
|
|
if [ -z "$ACCESS_TOKEN" ]; then
|
|
echo "❌ Authentication failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Authentication successful"
|
|
|
|
# Test collections
|
|
COLLECTIONS=("organizations" "asset_categories" "locations" "vendors" "assets")
|
|
|
|
echo "📊 Testing collection access..."
|
|
|
|
SUCCESS=0
|
|
TOTAL=0
|
|
|
|
for collection in "${COLLECTIONS[@]}"; do
|
|
TOTAL=$((TOTAL + 1))
|
|
|
|
RESPONSE=$(curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
|
|
"$DIRECTUS_URL/items/$collection?limit=1")
|
|
|
|
if echo "$RESPONSE" | grep -q '"data"'; then
|
|
echo " ✅ $collection - OK"
|
|
SUCCESS=$((SUCCESS + 1))
|
|
else
|
|
echo " ❌ $collection - FAILED"
|
|
echo " $(echo $RESPONSE | grep -o '"message":"[^"]*"' | cut -d'"' -f4)"
|
|
fi
|
|
done
|
|
|
|
echo
|
|
echo "📈 Results: $SUCCESS/$TOTAL collections accessible"
|
|
|
|
if [ $SUCCESS -eq $TOTAL ]; then
|
|
echo "🎉 All permissions working correctly!"
|
|
exit 0
|
|
else
|
|
echo "⚠️ Some permissions are missing. Run setup-permissions-enhanced.sh"
|
|
exit 1
|
|
fi |