✨ 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
|
// 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;
|
||||||
|
|||||||
@@ -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()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user