🔒 Add Discord admin user permissions and update developer access check logic

This commit is contained in:
2026-01-30 05:14:12 +00:00
parent e886fd62d1
commit 09fae4ef54
3 changed files with 149 additions and 11 deletions

View File

@@ -98,20 +98,14 @@ export function useDiscordOAuth() {
/**
* Check if user is allowed to access developer tools
* Compares Discord username against backend-managed allowlist
* Checks permissions returned from backend during OAuth
*
* @param {Object} userPermissions - User permissions object from backend
* @returns {boolean} True if user has developer access
*/
function hasDevAccess(userPermissions = {}) {
// Check explicit permission
if (userPermissions?.includes?.('developer_tools.view')) {
return true;
}
// Backend could also return discord_username_allowlist
// This would be checked server-side, but frontend can cache it
return false;
function hasDevAccess() {
// Check if tokens include permissions
const permissions = oauth.tokens.value?.permissions || [];
return permissions.includes('developer_tools.view');
}
return {