fix(admin): delete workspaces on ban#4029
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
@BugBot review |
PR SummaryMedium Risk Overview The admin user management UI is reworked to prevent action-button overlap by splitting each user row into a header row plus an inline “Confirm Ban” sub-row with an optional ban reason, and by toggling the Ban/Cancel state separately from the confirm action. Reviewed by Cursor Bugbot for commit eb96a73. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
@greptile review |
Greptile SummaryThis PR implements resource cleanup when a user is banned via the admin panel. It adds a Key observations:
Confidence Score: 4/5Safe to merge with caution — two P1 logic issues should be addressed before relying on this in production for multi-workspace users. The core intent is correct and workspace archiving idempotency makes repeated invocations harmless in the happy path. However, Promise.all short-circuit on failure is a real reliability gap for users with multiple workspaces, and the hook firing on every user update (not just the ban transition) is a latent correctness issue. apps/sim/lib/workflows/lifecycle.ts (Promise.all vs allSettled) and apps/sim/lib/auth/auth.ts (update.after triggering on every update, not just ban transition)
|
| Filename | Overview |
|---|---|
| apps/sim/lib/workflows/lifecycle.ts | Adds disableUserResources which archives owned workspaces and deletes user API keys on ban; also removes archivedAt from ArchiveWorkflowOptions and strips folder-clearing logic from restoreWorkflow. |
| apps/sim/lib/auth/auth.ts | Adds databaseHooks.user.update.after to fire disableUserResources when user.banned is truthy; removes isGithubAuthDisabled / isGoogleAuthDisabled guards (flags already removed from feature-flags.ts elsewhere). |
| apps/sim/app/workspace/[workspaceId]/settings/components/admin/admin.tsx | Refactors ban UI to a two-row layout to prevent button overflow; extracts the ban reason input and confirm button into a conditional second row below the user info row. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Admin bans user] --> B[BetterAuth updates user row]
B --> C{update.after hook}
C --> D{user.banned?}
D -- No --> E[No-op]
D -- Yes --> F[Call disableUserResources - fire and forget]
B --> G[Ban confirmed to admin]
F --> H[Query owned workspaces]
H --> I[Promise.all]
I --> J[archiveWorkspace for each]
I --> K[Delete personal API keys]
J --> L{Any promise rejected?}
L -- Yes --> M[Outer catch logs error - remaining workspaces may stay active]
L -- No --> N[All resources disabled]
Reviews (1): Last reviewed commit: "Fix lint" | Re-trigger Greptile
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eb96a73. Configure here.

Summary
Banning a user currently doesn't delete their resources or api keys. Switched this to delete all workspaces and associated resources that they own. This cleans api keys, mcp servers, deployed workflows, etc.
Also fixed formatting with ban action buttons overlapping other admin buttons.
Type of Change
Testing
Checklist
Screenshots/Videos