Repository navigation
fix(rbac/ui): gate Settings → Agent Save / Remove controls behind canAdmin - #142
Merged
Merged
Conversation
…Admin Closes #131. Same pattern as #141 — server-side /api/settings/anthropic-key PUT and DELETE already enforce role === 'admin' (returning 403 for anyone else), but the AgentSection rendered the Save input + Remove Key button to every member. Clicking either just produced an unhelpful toast. Wraps the new-key input, Save button, and Remove key button in a single canAdmin branch via the useUserRole hook landed in #141. Non-admin users see the same configured / unconfigured status block (GET is intentionally member-readable — only metadata is returned, never the key) plus a small 'Admin-only setting' banner explaining why the controls are gone.
Closed
7 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #131.
What
Same pattern as #141, smaller scope. The
/api/settings/anthropic-keyPUT and DELETE handlers already enforcerole === 'admin'(returning 403 for anyone else), butAgentSectionrendered the new-key Input, Save button, and Remove key button to every org member. Clicking any of them just produced an unhelpful toast from the catch.This PR wraps that whole control surface in a single
canAdminbranch using theuseUserRolehook landed in #141. The GET endpoint stays member-readable (it only returns metadata —configured,last4,set_at,set_by_email— never the plaintext), so non-admins still see the same configured / unconfigured status block.Non-admins now see:
Test plan
Out of scope
Other write surfaces still using the same admin-or-manager RLS posture (
brand_domains,brand_platforms,content_opportunities). Each becomes a small follow-up that reusesuseUserRole.