✨ Improve developer tools availability check logic
This commit is contained in:
@@ -137,15 +137,15 @@ const isOpen = ref(false);
|
||||
// Show in development mode or when authenticated with permission in production
|
||||
const isAvailable = computed(() => {
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
||||
|
||||
// Check JWT token permissions
|
||||
const hasJwtPermission = user.value?.permissions?.includes(
|
||||
'developer_tools.view'
|
||||
);
|
||||
|
||||
|
||||
// Check Discord OAuth permissions
|
||||
const hasDiscordPermission = discord.hasDevAccess();
|
||||
|
||||
|
||||
const hasPermission = hasJwtPermission || hasDiscordPermission;
|
||||
const isAuthenticatedInProduction =
|
||||
process.env.NODE_ENV === 'production' && hasPermission;
|
||||
|
||||
@@ -258,7 +258,7 @@ export function useOAuth(provider = 'challonge') {
|
||||
// Calculate token expiration time (expires_in is in seconds)
|
||||
const expiresAt = Date.now() + (data.expires_in || 3600) * 1000;
|
||||
|
||||
// Store tokens
|
||||
// Store tokens (including permissions if provided)
|
||||
const tokens = {
|
||||
access_token: data.access_token,
|
||||
refresh_token: data.refresh_token || null,
|
||||
@@ -266,6 +266,7 @@ export function useOAuth(provider = 'challonge') {
|
||||
expires_in: data.expires_in || 3600,
|
||||
expires_at: expiresAt,
|
||||
scope: data.scope,
|
||||
permissions: data.permissions || [], // Store permissions from backend
|
||||
created_at: Date.now()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user