User alice@example.com has 2 tenant groups but practice selection page is not showing.
After logging in with alice@example.com, open browser DevTools (F12) and check the Console tab for these logs:
Checking accessible tenants for user...
Tenants data: { hasFullAccess: false, tenants: [...], requiresSelection: true }
User has multiple tenants, redirecting to practice selection
In DevTools → Network tab, look for the request to /api/tenants/accessible:
Request:
- URL:
http://localhost:8080/api/tenants/accessible - Method: GET
- Headers should include:
Authorization: Bearer <token>
Expected Response:
{
"success": true,
"message": "Accessible tenants retrieved",
"data": {
"hasFullAccess": false,
"tenants": ["CareWell", "Qiaben Health"],
"requiresSelection": true
}
}In DevTools → Application → Local Storage → http://localhost:3000
Should have:
token: JWT tokengroups:["/Tenants/CareWell", "/Tenants/Qiaben Health"]selectedTenant: Should NOT be set yet (or should be empty)
Symptom: Network request to /api/tenants/accessible fails with 404 or 500
Solution:
- Make sure backend is running with
localprofile - Check if
TenantControllerhas the/api/tenants/accessibleendpoint - Restart backend:
SPRING_PROFILES_ACTIVE=local ./gradlew bootRun
Symptom: No network request to /api/tenants/accessible in Network tab
Solution:
- Check if
tenantService.tsexists insrc/utils/ - Check if callback page imports
getAccessibleTenants - Clear browser cache and try again
Symptom: selectedTenant is already in localStorage
Solution:
// In browser console, clear it:
localStorage.removeItem('selectedTenant');
// Then refresh and login againSymptom: requiresSelection is false even though user has 2 tenants
Solution:
- Check backend logs for errors
- Verify
TenantAccessService.getAccessibleTenants()is working correctly - Test endpoint manually with curl (see test_tenant_endpoint.sh)
Run this in browser console after login:
// Get token
const token = localStorage.getItem('token');
// Call endpoint
fetch('http://localhost:8080/api/tenants/accessible', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
})
.then(r => r.json())
.then(data => console.log('Response:', data))
.catch(err => console.error('Error:', err));Expected output:
Response: {
success: true,
data: {
hasFullAccess: false,
tenants: ["CareWell", "Qiaben Health"],
requiresSelection: true
}
}If all else fails, manually navigate to:
http://localhost:3000/select-practice
This should show the practice selection page if the endpoint is working.
Make sure the UI changes are compiled:
cd /home/siva/git/ciyex/ciyex-ehr-ui
# Install dependencies if needed
pnpm install
# Run dev server
pnpm devThen access: http://localhost:3000
❌ Backend not running with local profile
# Wrong
./gradlew bootRun
# Correct
SPRING_PROFILES_ACTIVE=local ./gradlew bootRun❌ UI not restarted after code changes
# Stop UI (Ctrl+C) and restart
pnpm dev❌ Old token in localStorage
// Clear everything and login fresh
localStorage.clear();❌ CORS issues
Check backend logs for CORS errors. Make sure application.yml has:
cors:
allowed-origins: http://localhost:3000If you just want to test the practice selection page directly:
- Login with alice@example.com
- Open browser console
- Run:
window.location.href = '/select-practice';This will take you directly to the practice selection page to verify it's working.