Skip to content

feat(admin): add send-password-reset-email toggle to create user modal - #6330

Closed
TheodoreSpeaks wants to merge 1 commit into
stagingfrom
feat/add-user-send-email
Closed

feat(admin): add send-password-reset-email toggle to create user modal#6330
TheodoreSpeaks wants to merge 1 commit into
stagingfrom
feat/add-user-send-email

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • Add a "Send password reset email" toggle to the admin create-user modal
  • On success it hits the same /api/auth/forget-password contract as the login form's "Forgot password", so the user gets the identical email and reset page
  • Toggle defaults off; password stays required
  • If the account is created but the email fails, the user is still reported to the admin view and a toast explains the email failure

Type of Change

  • New feature

Testing

Tested via unit tests (8 cases, incl. toggle off/on and the email-failure path). bun run lint, type-check, check:api-validation:strict, check:react-query, and the full ship audit suite pass.

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

vercelBot commented Aug 6, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 6, 2026 6:42pm

Request Review

@cursor

cursorBot commented Aug 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches admin user creation and password-reset email delivery; failures are handled without blocking user creation, but the flow is auth-adjacent.

Overview
Adds an optional Send password reset email toggle (default off) to the admin Add user modal. After a successful create, when the toggle is on, the modal triggers the same password-reset email flow as login’s forgot-password (useResetPassword with redirect to /reset-password).

Submit/close/cancel stay disabled while either create or reset-email is pending. If the user is created but the email fails, the admin still gets the new user in the list and an error toast; success path shows a confirmation toast.

Unit tests cover toggle off/on, pending UI, and the email-failure path.

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

@TheodoreSpeaks

Copy link
Copy Markdown
CollaboratorAuthor

Superseded by #6328, which shipped the same capability to staging first (as a 'Set a password' / 'Email a reset link' mode on the same modal). Closing in favor of that.

@greptile-apps

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds an optional password-reset email step after an administrator creates a user, while preserving successful user creation when email delivery fails.

  • Adds a disabled-by-default reset-email toggle and pending-state integration to the create-user modal.
  • Calls the existing forget-password contract after successful account creation and reports delivery success or failure with a toast.
  • Adds tests for enabled and disabled behavior, delivery failure, and pending-state locking.

Confidence Score: 4/5

The PR appears safe to merge, with one non-blocking modal-structure consistency issue in the new toggle field.

The user-creation and optional reset-email paths retain their intended success and failure behavior, but the new labeled switch bypasses the standardized ChipModalField wrapper required for controls inside ChipModalBody.

Files Needing Attention: apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.tsx

Important Files Changed

FilenameOverview
apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.tsxAdds the optional post-creation reset-email flow and pending-state handling; the new labeled switch does not use the repository-required ChipModalField structure.
apps/sim/app/workspace/[workspaceId]/settings/components/admin/add-user-modal.test.tsxExtends modal tests to cover the toggle-off, toggle-on, request-pending, and email-failure paths.

Sequence Diagram

sequenceDiagram
participant Admin
participant Modal as Create-user modal
participant Users as Add-user mutation
participant Reset as Reset-password mutation
Admin->>Modal: Submit user details
Modal->>Users: Create user
Users-->>Modal: Created user
alt Reset-email toggle enabled
Modal->>Reset: Send reset email
alt Email request succeeds
Reset-->>Modal: Success
Modal-->>Admin: Show success toast
else Email request fails
Reset-->>Modal: Error
Modal-->>Admin: Show partial-success error toast
end
end
Modal-->>Admin: Close modal and report created user
Loading

Reviews (1): Last reviewed commit: "feat(admin): add send-password-reset-ema..." | Re-trigger Greptile

Comment on lines 183 to +195
disabled={isSubmissionPending}
required
/>
<div className='flex items-center justify-between px-2'>
<Label htmlFor={resetEmailToggleId}>Send password reset email</Label>
<Switch
id={resetEmailToggleId}
checked={sendResetEmail}
disabled={isSubmissionPending}
onCheckedChange={(checked) => {
setSendResetEmail(checked)
addUser.reset()
}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2Use the standard modal field wrapper

The new labeled switch is rendered as a raw row inside ChipModalBody, bypassing the required ChipModalField type='custom' structure and its standardized field layout and accessibility behavior.

Context Used: Component patterns and structure for React compone... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@waleedlatif1
waleedlatif1 deleted the feat/add-user-send-email branch August 6, 2026 18:46
Sign up for freeto 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

@TheodoreSpeaks