Test these endpoints are responding:
# Test session creation
curl -X POST https://ultracard.io/wp-json/ultra-card/v1/session/create \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"device_id":"test","device_name":"Test Device","user_id":123}'
# Should return: {"success":true,"session_id":"sess_..."}Edit src/services/uc-cloud-auth-service.ts:
Find this (around line 75):
constructor() {
this._loadFromStorage();
this._setupAutoRefresh();
// Check for active cloud session on initialization
this._checkCloudSession();
}Change to:
constructor() {
this._loadFromStorage();
this._setupAutoRefresh();
// ENABLE CLOUD SESSION SYNC
ucSessionSyncService.enable();
// Check for active cloud session on initialization
this._checkCloudSession();
}cd "/Users/wayne/Ultra Card"
npm run build
# Deploy ultra-card.js to Home Assistant-
Clear cache on both devices
// In browser console localStorage.clear();
-
Login on Desktop
- Open Ultra Card editor
- Go to PRO tab
- Login with credentials
- Check console for:
✅ Cloud session created
-
Open Mobile Device
- Navigate to dashboard with Ultra Card
- Check console for:
✅ Found active cloud session - PRO features should work automatically
-
Test Logout Sync
- Logout on mobile
- Within 30 seconds, desktop should logout automatically
- Check console for:
⚠️ Session invalidated remotely
✅ Cloud session sync enabled
🔄 Creating cloud session...
✅ Cloud session created: sess_abc123xyz
🔄 Attempting to save to HA storage: ultra-card-pro-auth
✅ Saved to HA storage: ultra-card-pro-auth
🔄 Checking for active cloud session...
✅ Found active cloud session, syncing authentication
🔄 Starting session validation polling
✅ Cloud session invalidated
⚠️ Failed to create cloud session, using local-only mode: [error details]
⚠️ Failed to fetch cloud session: [error details]
If you see error messages, the backend API needs fixes.
- Check: Backend API endpoint responding
- Check: JWT token valid
- Check: WordPress REST API enabled
- Check: CORS headers configured
- Check: User actually logged in on other device
- Check: Session not expired (max 7 days)
- Check: Database table exists and has data
- Check: Session validation endpoint returning correct data
- Check: Database session record not corrupted
- Check: Session hasn't actually expired
- Check: Console shows "Found active cloud session"
- Check: Subscription data included in session response
- Check: JWT token in session is valid
If you need to disable cloud sync:
Edit src/services/uc-cloud-auth-service.ts:
constructor() {
this._loadFromStorage();
this._setupAutoRefresh();
// DISABLED - Backend not ready yet
// ucSessionSyncService.enable();
// Check for active cloud session on initialization
this._checkCloudSession();
}Rebuild and deploy. Auth will work in localStorage-only mode.
- Polling: Every 30 seconds per device
- API Calls: ~2 requests/minute per authenticated device
- Data Transfer: <1KB per request
- Server Load: Minimal (simple SELECT query)
With 100 active PRO users:
- ~200 requests/minute to validation endpoint
- Easily handled by WordPress/MySQL
-
Session Hijacking Protection:
- Device ID tracked with each session
- Can implement device verification on critical actions
-
Token Security:
- JWT tokens stored server-side only
- Not exposed in localStorage on client
-
Session Expiry:
- Auto-expires after 7 days inactivity
- Can be invalidated immediately by user
-
Concurrent Sessions:
- Multiple devices can share same session
- Optional: Add device limit per user
Edit src/services/uc-session-sync-service.ts:
private static readonly POLL_INTERVAL = 30000; // Change to desired msEdit backend API session creation to use different expiry time:
// Default: 7 days
$expires_at = date('Y-m-d H:i:s', strtotime('+7 days'));
// Change to 30 days:
$expires_at = date('Y-m-d H:i:s', strtotime('+30 days'));In backend API, check active sessions count before creating new one:
$active_sessions = count_user_sessions($user_id);
if ($active_sessions >= 5) {
return new WP_Error('too_many_devices', 'Maximum 5 devices allowed');
}Query database:
SELECT
session_id,
user_id,
device_name,
created_at,
last_validated,
expires_at
FROM wp_ultra_card_sessions
WHERE expires_at > NOW()
ORDER BY last_validated DESC;Manual cleanup:
DELETE FROM wp_ultra_card_sessions
WHERE expires_at < NOW();Set up cron job to run this daily.
If issues persist after following this guide:
- Check browser console for detailed error messages
- Check WordPress error logs
- Verify all 4 API endpoints are responding correctly
- Test with Postman to isolate frontend vs backend issues
Once enabled, users will experience seamless cross-device authentication without any manual intervention!