Skip to content

feat(admin): add password user creation - #6267

Merged
TheodoreSpeaks merged 5 commits into
stagingfrom
feat/canary-coverage
Aug 4, 2026
Merged

feat(admin): add password user creation#6267
TheodoreSpeaks merged 5 commits into
stagingfrom
feat/canary-coverage

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add an admin-panel flow for creating Better Auth credential users without an OAuth account
  • hardcode newly created accounts to the normal user role while preserving Better Auth user and account hooks
  • support email-verification status and add focused tests for validation, payload normalization, success, and error states

Type of Change

  • New feature

Testing

  • 7 focused Vitest tests passing
  • Sim TypeScript type-check passing
  • Full repository lint and ship audit suite passing
  • Local development server and authenticated-route redirect verified

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 4, 2026 11:45pm

Request Review

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Introduces admin-driven account creation with passwords and email-verification flags via Better Auth; role is fixed to user, but the surface is still authentication-sensitive and should rely on existing admin authorization.

Overview
Adds admin user creation for Better Auth credential accounts from workspace admin settings.

A new Add user control opens AddUserModal with name, email, password (min 8 chars), and email status (verified vs unverified). Submissions go through addUser / useAddUser, which call client.admin.createUser with trimmed/lowercased identity fields, fixed platform role user, and emailVerified in data. On success the modal closes and the user list search is set to the new email. API errors stay in the modal via ChipModalError.

Vitest covers modal validation, success paths, unverified flow (no platform-role UI), and Better Auth error handling, plus addUser normalization and error surfacing.

Reviewed by Cursor Bugbot for commit 1e2bfb2. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds an admin flow for creating password-based Better Auth users and displaying the resulting account through the existing user search.

  • Adds a credential-user creation modal with validation, verification-state selection, pending-state protection, and error handling.
  • Adds a React Query mutation that normalizes identity fields, fixes the platform role to user, and refreshes admin-user queries.
  • Extends the shared modal header with a disabled-close-button state.
  • Adds focused tests for payload normalization, validation, duplicate submission, success, and errors.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.tsx Adds the validated, guarded credential-user creation form and mutation lifecycle handling.
apps/sim/hooks/queries/admin-users.ts Adds normalized Better Auth credential-user creation and invalidates user-list queries after completion.
apps/sim/app/workspace/[workspaceId]/settings/components/admin/admin.tsx Integrates the creation modal and searches for the newly created account on success.
packages/emcn/src/components/chip-modal/chip-modal.tsx Adds an optional disabled state to the modal header close button.
apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsx Covers validation, normalization, success, duplicate submission, verification status, and displayed errors.
apps/sim/hooks/queries/admin-users.test.ts Covers the Better Auth request shape, resolved API errors, and missing-user responses.

Sequence Diagram

sequenceDiagram
  participant Admin
  participant Modal as AddUserModal
  participant Mutation as useAddUser
  participant Auth as Better Auth
  participant Query as Admin Users Query
  Admin->>Modal: Enter name, email, password, verification status
  Modal->>Mutation: Submit normalized AddUserInput
  Mutation->>Auth: "admin.createUser(role=user)"
  Auth-->>Mutation: Created user or error
  alt Creation succeeds
    Mutation-->>Modal: AdminUser
    Modal-->>Admin: onCreated(user)
    Admin->>Query: Search for created email
    Mutation->>Query: Invalidate user-list queries
  else Creation fails
    Mutation-->>Modal: Display creation error
  end
Loading

Reviews (3): Last reviewed commit: "fix(admin): reflect immediate submission..." | Re-trigger Greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.tsx Outdated
@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 44dfe92. Configure here.

@TheodoreSpeaks
TheodoreSpeaks merged commit fbd02bc into staging Aug 4, 2026
30 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the feat/canary-coverage branch August 4, 2026 23:48
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.

1 participant