Improve developer tools availability check logic

This commit is contained in:
2026-01-30 05:40:42 +00:00
parent 7c512f410f
commit 8daf9128bd
2 changed files with 5 additions and 4 deletions

View File

@@ -137,15 +137,15 @@ const isOpen = ref(false);
// Show in development mode or when authenticated with permission in production // Show in development mode or when authenticated with permission in production
const isAvailable = computed(() => { const isAvailable = computed(() => {
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
// Check JWT token permissions // Check JWT token permissions
const hasJwtPermission = user.value?.permissions?.includes( const hasJwtPermission = user.value?.permissions?.includes(
'developer_tools.view' 'developer_tools.view'
); );
// Check Discord OAuth permissions // Check Discord OAuth permissions
const hasDiscordPermission = discord.hasDevAccess(); const hasDiscordPermission = discord.hasDevAccess();
const hasPermission = hasJwtPermission || hasDiscordPermission; const hasPermission = hasJwtPermission || hasDiscordPermission;
const isAuthenticatedInProduction = const isAuthenticatedInProduction =
process.env.NODE_ENV === 'production' && hasPermission; process.env.NODE_ENV === 'production' && hasPermission;

View File

@@ -258,7 +258,7 @@ export function useOAuth(provider = 'challonge') {
// Calculate token expiration time (expires_in is in seconds) // Calculate token expiration time (expires_in is in seconds)
const expiresAt = Date.now() + (data.expires_in || 3600) * 1000; const expiresAt = Date.now() + (data.expires_in || 3600) * 1000;
// Store tokens // Store tokens (including permissions if provided)
const tokens = { const tokens = {
access_token: data.access_token, access_token: data.access_token,
refresh_token: data.refresh_token || null, refresh_token: data.refresh_token || null,
@@ -266,6 +266,7 @@ export function useOAuth(provider = 'challonge') {
expires_in: data.expires_in || 3600, expires_in: data.expires_in || 3600,
expires_at: expiresAt, expires_at: expiresAt,
scope: data.scope, scope: data.scope,
permissions: data.permissions || [], // Store permissions from backend
created_at: Date.now() created_at: Date.now()
}; };