- Created new markdown file for Support Ticket - 3224942 with a link to the support page. - Added a separate markdown file for Supprt Tickets with the same link. - Updated workspace files to include new markdown files and attachments. - Added various attachments related to the support ticket, including images and PDFs.
4.1 KiB
4.1 KiB
Discord User Permissions Setup Guide
Overview
The app now checks Discord usernames/IDs to grant developer tool access. Users must be in the allowlist to access developer features.
Configuration
1. Find Your Discord Username/ID
You can use any of the following to identify users:
- Username: Your current Discord username (e.g.,
fragginwagon) - Global Name: Your display name (if different from username)
- Discord ID: Your numeric Discord ID (e.g.,
123456789012345678)
How to Find Your Discord ID:
- Enable Developer Mode in Discord: Settings → Advanced → Developer Mode (ON)
- Right-click your username anywhere → Copy User ID
- Or use this Discord bot command:
/userinfoor!userinfo
2. Configure Environment Variables
Add allowed users to your .env file:
# Discord User Permissions
# Comma-separated list of Discord usernames, display names, or IDs
DISCORD_ADMIN_USERS=fragginwagon,AnotherUser,123456789012345678
Multiple formats supported:
# Just usernames
DISCORD_ADMIN_USERS=fragginwagon,coolguy99
# Mix of usernames and IDs
DISCORD_ADMIN_USERS=fragginwagon,123456789012345678,coolguy99
# Using Discord IDs (most reliable)
DISCORD_ADMIN_USERS=123456789012345678,987654321098765432
3. Location of Configuration
Development (.env file):
/Users/fragginwagon/Developer/MemoryPalace/code/websites/pokedex.online/server/.env
Production (Docker):
Add to your docker-compose.tmp.yml or production environment:
environment:
- DISCORD_ADMIN_USERS=fragginwagon,user2,123456789012345678
Or in your server's .env file that gets loaded by Docker.
How It Works
- User logs in with Discord OAuth
- Backend fetches user info from Discord API
- Backend checks if username, global name, OR Discord ID matches the allowlist
- Backend returns
permissions: ['developer_tools.view']if user is authorized - Frontend checks
hasDevAccess()to show/hide developer tools
Testing
Test if you're in the allowlist:
- Add your Discord username to
DISCORD_ADMIN_USERSin.env - Restart the backend server:
docker compose -f docker-compose.tmp.yml restart backend - Log in with Discord OAuth in the app
- Open Developer Tools (should now be visible if authorized)
Check backend logs:
Look for these messages:
✅ Discord user authenticated { username: 'fragginwagon', id: '123456789012345678' }
✅ Discord user granted developer access { username: 'fragginwagon' }
Or if not authorized:
✅ Discord user authenticated { username: 'unauthorized', id: '999999999999999999' }
Security Notes
- Case-insensitive matching: Usernames are compared in lowercase
- Multiple formats: Supports username, display name, and Discord ID
- Fallback behavior: If Discord user info fetch fails, no permissions are granted (fail-safe)
- No permissions stored client-side: Permissions are checked on every OAuth login
Troubleshooting
Developer tools not appearing after adding username:
- Check backend logs for "Discord user authenticated" message
- Verify your username matches exactly (check for typos)
- Try using your Discord ID instead of username (more reliable)
- Ensure backend restarted after changing
.env
"Failed to fetch Discord user info" in logs:
- OAuth token may not have
identifyscope - Check Discord OAuth app settings
- Verify
VITE_DISCORD_CLIENT_IDandDISCORD_CLIENT_SECRETare correct
Example Configuration
# Development
NODE_ENV=development
PORT=3099
# Discord OAuth
VITE_DISCORD_CLIENT_ID=your_client_id_here
DISCORD_CLIENT_SECRET=your_client_secret_here
VITE_DISCORD_REDIRECT_URI=http://localhost:5173/oauth/callback
# Allowed Users (add your Discord username or ID)
DISCORD_ADMIN_USERS=fragginwagon,123456789012345678
Permission Levels
Currently implemented:
developer_tools.view- Access to developer tools panel and feature flags
Future permissions (not yet implemented):
admin- Full admin accessgamemaster.edit- Edit gamemaster datatournaments.manage- Manage tournaments