Skip to content

fix(visibility): allow chatflow owners to change visibility settings#1055

Open
diecoscai wants to merge 15 commits into
stagingfrom
fix/preserve-auth-fields
Open

fix(visibility): allow chatflow owners to change visibility settings#1055
diecoscai wants to merge 15 commits into
stagingfrom
fix/preserve-auth-fields

Conversation

@diecoscai
Copy link
Copy Markdown

Summary

  • Chatflow owners can now toggle Organization and Browser Extension visibility on their own chatflows
  • Previously only org admins (org:manage) could change these settings — owners of chatflows were locked out
  • Non-owners without admin role remain blocked (unchanged)

Changes

  • packages/ui/src/ui-component/extended/VisibilitySettings.jsx:
    • Added user selector and isOwner ownership check (user.id === chatflow.userId)
    • Changed disable condition from !canManageOrg to !canManageOrg && !isOwner for Organization and Browser Extension checkboxes

Permission matrix

User Can toggle Org/Browser Extension?
Chatflow owner (any role) Yes (new)
Admin (any chatflow) Yes (unchanged)
Non-owner, non-admin No (unchanged)

Test plan

  • Owner (Builder role): open own chatflow → Organization and Browser Extension checkboxes enabled → change → save → verify persisted
  • Admin: can change visibility on any chatflow (unchanged behavior)
  • Non-owner, non-admin: checkboxes disabled on someone else's chatflow
  • Verify chatflow.userId is present in Redux after loading a chatflow

🤖 Generated with Claude Code

diecoscai and others added 15 commits March 20, 2026 12:48
…rsation

fix(chat): restore chatId/sessionId filtering lost during Flowise 3.0.11 merge
The mergeUsers function was overwriting server-enriched permission data
(roles, permissions, features) with client-side Auth0 data that lacks
these fields. This caused Admin users to fail permission checks because
hasFeature('org:manage') would return false despite having the role.

The fix explicitly preserves auth fields from the server (initialUser)
and only allows runtime updates for non-auth fields (name, email, picture).

Fixes visibility settings not working for Admin users.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…s token lacks claim

The access token sent to Flowise does not carry the https://theanswer.ai/roles
custom claim (only the ID token does). verifyAAIToken extracts roles from the
access token and gets roles=[], causing enrichUserWithAAIData to return empty
roles/permissions/features, which then overwrites the correct roles from the
Auth0 session in the merge.

Save https://theanswer.ai/roles from the session before the Flowise merge and
restore it afterward if Flowise returned an empty roles array.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ider

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
useAuth0() from @auth0/auth0-react has no Auth0Provider in the Flowise
UI component tree — only UserProvider from @auth0/nextjs-auth0/client
is present. This caused useAuth0() to return undefined, making
createPermissionManager receive an empty object, which disabled all
visibility checkboxes for every user.

Fix: read from Redux state.auth.user, which is populated by useAuth0Setup
after /auth/me enrichment and contains the correct roles and permissions.
…d Browser Extension visibility

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…er, guard, error re-throw

- Add organizationId filter to getBrowserExtensionChatflows query for multi-tenancy compliance
- Add activeWorkspaceId guard that throws PRECONDITION_FAILED before the query runs
- Re-throw InternalFlowiseError in both catch blocks so NOT_FOUND/FORBIDDEN preserve their status codes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…kspace and org

Add activeWorkspaceId and organizationId guards before query, then scope
findOneBy to { id, workspaceId, organizationId } — matching the pattern
in getBrowserExtensionChatflows and all other services (tools, assistants,
credentials, variables). Prevents cross-workspace visibility toggling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace triple-key filter (userId + workspaceId + organizationId) with
workspace-scoped dual-path query: show user's own chatflows AND chatflows
shared with the organization via (userId OR Organization visibility).

Remove redundant organizationId guard and filter from update path —
checkOwnership and enforceAbility already handle org-level auth.

Closes #1054

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add ownership check to VisibilitySettings — chatflow owners can now
toggle Organization and Browser Extension visibility on their own
chatflows, not just org admins. Non-owners without admin role remain
blocked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@diecoscai diecoscai self-assigned this Apr 16, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
answerai-docs Building Building Preview Apr 16, 2026 5:48pm
the-answerai Building Building Preview Apr 16, 2026 5:48pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants