3.7 KiB
3.7 KiB
Temp User Implementation Test Guide
Testing the Implementation
1. Database Setup
Before testing, ensure your NocoDB Login table has these columns:
UserType(Single Select: admin, user, temp)ExpiresAt(DateTime, nullable)CreatedAt(DateTime)ExpireDays(Integer, nullable)
2. Test User Creation via Admin Panel
-
Access Admin Panel
- Login as an admin user
- Navigate to
/admin.html - Go to the "Users" section
-
Create Regular User
- Email:
testuser@example.com - Name:
Test User - Password:
password123 - User Type:
Regular User - Click "Create User"
- Email:
-
Create Temp User
- Email:
tempuser@example.com - Name:
Temp User - Password:
password123 - User Type:
Temporary User - Expires After:
30days - Click "Create User"
- Email:
-
Create Admin User
- Email:
adminuser@example.com - Name:
Admin User - Password:
password123 - User Type:
Admin - Click "Create User"
- Email:
3. Test User Permissions
Test Temp User Restrictions:
-
Login as temp user (
tempuser@example.com) -
Verify UI Elements Hidden:
- No "Shifts" link in navigation
- No "Profile" link in navigation
- User email shows "Temp" badge
- Map search only shows "docs" mode (no database search)
-
Test Location Operations:
- ✅ Add Location: Should work
- ✅ Edit Location: Should work
- ❌ Delete Location: Delete button should be hidden in edit form
- ❌ Move Location: Move button should be hidden in popup
-
Test Restricted Access:
- Navigate to
/shifts.html→ Should redirect or show 403 - Navigate to
/user.html→ Should redirect or show 403 - Navigate to
/admin.html→ Should redirect or show 403
- Navigate to
Test Regular User:
-
Login as regular user (
testuser@example.com) -
Verify Full Access:
- ✅ Can access shifts page
- ✅ Can access user profile
- ✅ Can add, edit, and delete locations
- ✅ Can use database search
- ❌ Cannot access admin panel
Test Admin User:
-
Login as admin user (
adminuser@example.com) -
Verify Admin Access:
- ✅ Full access to all features
- ✅ Can access admin panel
- ✅ Can create/manage users
4. Test Backend API Endpoints
Use browser console or testing tool:
// Test temp user cannot delete location
fetch('/api/locations/1', { method: 'DELETE' })
.then(r => r.json())
.then(console.log); // Should return 403 error for temp users
// Test temp user cannot access shifts
fetch('/api/shifts')
.then(r => r.json())
.then(console.log); // Should return 403 error for temp users
5. Expected Results
User Table Display:
- Regular User: Blue "User" badge
- Temp User: Orange "Temp" badge + expiration date
- Admin User: Green "Admin" badge
Authentication Response:
{
"authenticated": true,
"user": {
"email": "tempuser@example.com",
"name": "Temp User",
"isAdmin": false,
"userType": "temp"
}
}
6. Troubleshooting
If temp user can access restricted features:
- Check middleware is properly imported in routes
- Verify session includes
userType - Check browser console for JavaScript errors
If user creation fails:
- Verify NocoDB table has required columns
- Check server logs for database errors
- Ensure column names match exactly
If UI elements not hiding:
- Check browser console for auth errors
- Verify
currentUser.userTypeis set - Check CSS classes are applied correctly
7. Security Verification
Temp users should receive 403 Forbidden responses for:
DELETE /api/locations/:idGET /shifts.htmlGET /user.htmlGET /admin.htmlGET /api/shifts
All restrictions should be enforced server-side, not just hidden in UI.