#!/bin/bash

echo "=== Verifying Joe User Configurations ==="
echo "Date: $(date)"
echo

# SSH connection details
SERVER="146.190.76.204"
USER="roodev"

echo "🔍 Checking user configurations on staging server..."

# Check user configurations via SSH
ssh ${USER}@${SERVER} << 'EOF'
cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html

echo "=== Joe User Verification ==="

# Check joe@measurequick.com
echo "🔍 Checking joe@measurequick.com..."
wp user get joe@measurequick.com --fields=ID,user_login,user_email,user_pass,roles 2>/dev/null
if [ $? -eq 0 ]; then
    echo "✅ joe@measurequick.com user exists and accessible"
    
    # Test password (if needed, reset it)
    echo "🔧 Ensuring password is set correctly..."
    wp user update joe@measurequick.com --user_pass=JoeTrainer2025@
    echo "✅ Password updated for joe@measurequick.com"
else
    echo "❌ joe@measurequick.com user not accessible"
fi

echo

# Check joe@upskillhvac.com
echo "🔍 Checking joe@upskillhvac.com..."
wp user get joe@upskillhvac.com --fields=ID,user_login,user_email,user_pass,roles 2>/dev/null
if [ $? -eq 0 ]; then
    echo "✅ joe@upskillhvac.com user exists and accessible"
    
    # Test password (if needed, reset it)
    echo "🔧 Ensuring password is set correctly..."
    wp user update joe@upskillhvac.com --user_pass=JoeTrainer2025@
    echo "✅ Password updated for joe@upskillhvac.com"
else
    echo "❌ joe@upskillhvac.com user not accessible"
fi

echo
echo "=== All HVAC Users Summary ==="
wp user list --role=hvac_trainer --fields=ID,user_login,user_email,roles --format=table
echo
wp user list --role=hvac_master_trainer --fields=ID,user_login,user_email,roles --format=table

EOF

echo "✅ User verification completed!"