Explorar el Código

fix: allow superadmins to access LLM chat without workspace context

The usePermissions hook now grants superadmins wildcard permission even
when no workspaceId is provided, enabling access to system-level
features like the LLM chat widget.
fszontagh hace 6 meses
padre
commit
806e26d247
Se han modificado 1 ficheros con 15 adiciones y 1 borrados
  1. 15 1
      webui/src/hooks/usePermissions.ts

+ 15 - 1
webui/src/hooks/usePermissions.ts

@@ -51,12 +51,26 @@ export function usePermissions({
   const [error, setError] = useState<string | null>(null)
 
   const fetchPermissions = useCallback(async () => {
-    if (!workspaceId || !isAuthenticated || !user) {
+    if (!isAuthenticated || !user) {
       setPermissions([])
       setUserGroups([])
       return
     }
 
+    // Superadmins always get wildcard permission (for system-level permissions)
+    if (user.is_superadmin) {
+      setPermissions(['*'])
+    }
+
+    // If no workspaceId, we can only check superadmin status
+    if (!workspaceId) {
+      if (!user.is_superadmin) {
+        setPermissions([])
+      }
+      setUserGroups([])
+      return
+    }
+
     setIsLoading(true)
     setError(null)