Skip to content

chore: migrate web-ui-registration DDP callers to REST (resetPassword, checkRegistrationSecretURL) - #41455

Draft
ggazzo wants to merge 4 commits into
developfrom
chore/ddp-migrate-registration
Draft

chore: migrate web-ui-registration DDP callers to REST (resetPassword, checkRegistrationSecretURL)#41455
ggazzo wants to merge 4 commits into
developfrom
chore/ddp-migrate-registration

Conversation

@ggazzo

@ggazzo ggazzo commented Jul 17, 2026

Copy link
Copy Markdown
Member

Proposal (ARCH-2166)

Migrates the two remaining web-ui-registration DDP callers to REST.

Changes

  • checkRegistrationSecretURL → new GET /v1/misc.registrationSecretCheck (query { hash }{ valid }), authRequired: false, rate-limited. The DDP method keeps its registration with a deprecation log pointing at the new route until 9.0.0.
  • resetPassword → new POST /v1/users.resetPassword (body { token, newPassword }{ token }), authRequired: false, rate-limited. The ResetPassword page now uses it and resumes the returned login token.

⚠️ Draft — needs review

  • resetPassword is a Meteor core accounts-password method; the endpoint currently delegates via Meteor.callAsync('resetPassword', ...). Its behavior invoked server-side (no DDP connection) needs verifying — it may need reimplementing directly against Accounts (validate reset token → set password → issue login token). See the TODO(review) in users.ts.
  • No e2e tests yet. The twoFactorRequired-style gates aren't exercisable in the API e2e suite anyway (TEST_MODE bypasses 2FA unless requireSecondFactor is set), so any tests here would only cover the happy/validation paths.

/jira ARCH-2166

🤖 Generated with Claude Code

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added REST API support for checking registration secret URLs.
    • Added REST API support for resetting passwords with a reset token.
    • Registration and password-reset flows now use the new REST endpoints.
  • Documentation

    • Added migration guidance for the previous DDP methods, which remain available temporarily with deprecation notices.

- checkRegistrationSecretURL -> GET /v1/misc.registrationSecretCheck (DDP method deprecated)
- resetPassword -> POST /v1/users.resetPassword (delegates to accounts-password reset)

DRAFT: the resetPassword endpoint wraps Meteor.callAsync('resetPassword') — the
server-side behavior of that built-in login method (no DDP connection) needs review.
@dionisio-bot

dionisio-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is targeting the wrong base branch. It should target 8.8.0, but it targets 8.7.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9397ee5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@rocket.chat/rest-typings Minor
@rocket.chat/meteor Minor
@rocket.chat/web-ui-registration Patch
@rocket.chat/core-typings Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04f13865-0bff-494c-a215-05d0f41fc9da

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Registration secret validation and password reset callers migrate from DDP methods to typed REST endpoints. The server adds unauthenticated, rate-limited routes, while the legacy registration-secret method logs deprecation and the password-reset method remains registered.

Changes

Registration REST migration

Layer / File(s) Summary
Registration secret REST check
packages/rest-typings/src/v1/misc.ts, apps/meteor/server/api/v1/misc.ts, apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts, packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts, .changeset/ddp-migrate-registration.md
Adds the typed GET /v1/misc.registrationSecretCheck route, updates the registration hook to consume { valid }, and deprecates the legacy DDP method through version 9.0.0.
Password reset REST flow
packages/rest-typings/src/v1/users.ts, apps/meteor/server/api/v1/users.ts, packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx
Adds the typed POST /v1/users.resetPassword route, delegates to Meteor’s password-reset method, returns the resume login token, and updates the reset page payload.
Estimated code review effort: 3 (Moderate) ~20 minutes

Suggested labels: type: chore

Suggested reviewers: sampaiodiego, sampaiodiego, tassoevan

Sequence Diagram(s)

Registration secret validation

sequenceDiagram
  participant RegistrationUI
  participant MiscREST
  participant ServerSettings
  RegistrationUI->>MiscREST: GET /v1/misc.registrationSecretCheck with hash
  MiscREST->>ServerSettings: Read Accounts_RegistrationForm_SecretURL
  ServerSettings-->>MiscREST: Configured secret hash
  MiscREST-->>RegistrationUI: Return valid
Loading

Password reset

sequenceDiagram
  participant ResetPasswordPage
  participant UsersREST
  participant MeteorAccounts
  ResetPasswordPage->>UsersREST: POST /v1/users.resetPassword with token and newPassword
  UsersREST->>MeteorAccounts: Call resetPassword(token, newPassword)
  MeteorAccounts-->>UsersREST: Return resume login token
  UsersREST-->>ResetPasswordPage: Return token
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating web-ui-registration DDP callers to REST.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2166: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.39%. Comparing base (f8d6b46) to head (9397ee5).
⚠️ Report is 142 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41455      +/-   ##
===========================================
- Coverage    68.52%   68.39%   -0.14%     
===========================================
  Files         4128     4157      +29     
  Lines       160182   158884    -1298     
  Branches     29167    28422     -745     
===========================================
- Hits        109771   108668    -1103     
+ Misses       45311    45002     -309     
- Partials      5100     5214     +114     
Flag Coverage Δ
unit 70.55% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggazzo ggazzo added this to the 8.7.0 milestone Jul 17, 2026
@ggazzo
ggazzo marked this pull request as ready for review July 17, 2026 21:05
@ggazzo
ggazzo requested review from a team as code owners July 17, 2026 21:05

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/meteor/server/api/v1/users.ts`:
- Around line 2129-2169: Replace the Meteor.callAsync invocation in the
users.resetPassword action with the underlying server-side Accounts APIs,
validating the reset token, updating the password, and obtaining the resulting
login token without relying on a DDP connection. Preserve the endpoint’s
existing success response and error behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e6df2be9-a25e-437c-8d07-c895a20902d7

📥 Commits

Reviewing files that changed from the base of the PR and between f8d6b46 and dd11148.

📒 Files selected for processing (8)
  • .changeset/ddp-migrate-registration.md
  • apps/meteor/server/api/v1/misc.ts
  • apps/meteor/server/api/v1/users.ts
  • apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts
  • packages/rest-typings/src/v1/misc.ts
  • packages/rest-typings/src/v1/users.ts
  • packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx
  • packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
⚠️ CI failures not shown inline (1)

GitHub Actions: Code scanning - action / 0_CodeQL-Build.txt: chore: migrate web-ui-registration DDP callers to REST (resetPassword, checkRegistrationSecretURL)

Conclusion: failure

View job details

##[group]Run github/codeql-action/autobuild@7188fc363630916deb702c7fdcf4e481b751f97a
 with:
   ***REDACTED***
   matrix: null
 env:
   CODEQL_ACTION_FEATURE_MULTI_LANGUAGE: false
   CODEQL_ACTION_FEATURE_SANDWICH: false
   CODEQL_ACTION_FEATURE_SARIF_COMBINE: true
   CODEQL_ACTION_FEATURE_WILL_UPLOAD: true
   CODEQL_ACTION_VERSION: 4.36.2
   JOB_RUN_UUID: d1c20fda-8596-4e3d-bbb2-3f49942a3454
   CODEQL_ACTION_INIT_HAS_RUN: true
   CODEQL_ACTION_ANALYSIS_KEY: .github/workflows/codeql-analysis.yml:CodeQL-Build
   CODEQL_WORKFLOW_STARTED_AT:
   CODEQL_ACTION_CLI_VERSION_INFO: {"cmd":"/opt/hostedtoolcache/CodeQL/2.26.1/x64/codeql/codeql","version":{"productName":"CodeQL","vendor":"GitHub","version":"2.26.1","sha":"1ffdebae722922fb50a64b14a97789ed6161f4a7","branches":["codeql-cli-2.26.1"],"copyright":"Copyright (C) 2019-2026 GitHub, Inc.","unpackedLocation":"/opt/hostedtoolcache/CodeQL/2.26.1/x64/codeql","configFileLocation":"/home/runner/.config/codeql/config","configFileFound":false,"overlayVersion":4,"features":{"analysisSummaryV2Default":true,"buildModeOption":true,"bundleSupportsIncludeDiagnostics":true,"bundleSupportsIncludeLogs":true,"bundleSupportsOverlay":true,"databaseInterpretResultsSupportsSarifRunProperty":true,"featuresInVersionResult":true,"indirectTracingSupportsStaticBinaries":false,"informsAboutUnsupportedPathFilters":true,"supportsPython312":true,"mrvaPackCreate":true,"threatModelOption":true,"traceCommandUseBuildMode":true,"v2ramSizing":true,"mrvaPackCreateMultipleQueries":true,"setsCodeqlRunnerEnvVar":true,"sarifMergeRunsFromEqualCategory":true,"forceOverwrite":true,"generateSummarySymbolMap":true,"pythonDefaultIsToNotExtractStdlib":true,"queryServerRunQueries":true,"queryServerTrimCacheWithMode":true,"builtinExtractorsSpecifyDefaultQueries":true,"bqrsDiffResultSets":true,"bundleSupportsIncludeOption":true,"suppressesMissingFileBaselineWarning":true}}}
   CODEQL_RAM: 14575
   CODEQL_THREADS: 4
 ##[endgroup]
 ##[error]We were unable to automatically...
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts
  • packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts
  • packages/rest-typings/src/v1/users.ts
  • packages/rest-typings/src/v1/misc.ts
  • apps/meteor/server/api/v1/users.ts
  • apps/meteor/server/api/v1/misc.ts
  • packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx
🧠 Learnings (6)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts
  • packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts
  • packages/rest-typings/src/v1/users.ts
  • packages/rest-typings/src/v1/misc.ts
  • apps/meteor/server/api/v1/users.ts
  • apps/meteor/server/api/v1/misc.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts
  • packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts
  • packages/rest-typings/src/v1/users.ts
  • packages/rest-typings/src/v1/misc.ts
  • apps/meteor/server/api/v1/users.ts
  • apps/meteor/server/api/v1/misc.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts
  • packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts
  • packages/rest-typings/src/v1/users.ts
  • packages/rest-typings/src/v1/misc.ts
  • apps/meteor/server/api/v1/users.ts
  • apps/meteor/server/api/v1/misc.ts
  • packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/ddp-migrate-registration.md
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.

Applied to files:

  • packages/rest-typings/src/v1/users.ts
  • packages/rest-typings/src/v1/misc.ts
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx
🔇 Additional comments (7)
packages/rest-typings/src/v1/misc.ts (1)

263-266: LGTM!

apps/meteor/server/api/v1/misc.ts (1)

887-921: LGTM!

apps/meteor/server/meteor-methods/auth/checkRegistrationSecretURL.ts (1)

5-10: LGTM!

packages/web-ui-registration/src/hooks/useCheckRegistrationSecret.ts (1)

1-5: LGTM!

Also applies to: 14-15

.changeset/ddp-migrate-registration.md (1)

1-10: LGTM!

packages/rest-typings/src/v1/users.ts (1)

274-277: LGTM!

packages/web-ui-registration/src/ResetPassword/ResetPasswordPage.tsx (1)

29-29: LGTM!

Also applies to: 71-71

Comment thread apps/meteor/server/api/v1/users.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

1 issue found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/server/api/v1/misc.ts">

<violation number="1" location="apps/meteor/server/api/v1/misc.ts:889">
P3: The new public route has no automated coverage, so regressions in the validation contract, `{ valid, success }` response, or anonymous rate limiting would not be caught. A focused API test covering valid and invalid hashes plus malformed/extra query parameters would make this migration verifiable.

(Based on your team's feedback about meaningful behavior and edge-case tests.)</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/server/api/v1/users.ts Outdated
Comment thread .changeset/ddp-migrate-registration.md Outdated
);

API.v1.get(
'misc.registrationSecretCheck',

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.

P3: The new public route has no automated coverage, so regressions in the validation contract, { valid, success } response, or anonymous rate limiting would not be caught. A focused API test covering valid and invalid hashes plus malformed/extra query parameters would make this migration verifiable.

(Based on your team's feedback about meaningful behavior and edge-case tests.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/server/api/v1/misc.ts, line 889:

<comment>The new public route has no automated coverage, so regressions in the validation contract, `{ valid, success }` response, or anonymous rate limiting would not be caught. A focused API test covering valid and invalid hashes plus malformed/extra query parameters would make this migration verifiable.

(Based on your team's feedback about meaningful behavior and edge-case tests.) </comment>

<file context>
@@ -884,3 +884,38 @@ API.v1.post(
 );
+
+API.v1.get(
+	'misc.registrationSecretCheck',
+	{
+		authRequired: false,
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added in 95c4233[/misc.registrationSecretCheck] API tests covering the configured secret (valid: true), a wrong secret (valid: false), and a missing hash param (400), reusing the existing secret-URL registration setup.

ggazzo added 3 commits July 29, 2026 17:37
The core accounts-password resetPassword method issues its login token through
the DDP connection, which is unavailable over REST (this.connection is null).
Reimplement the flow directly: validate the reset token and its expiry, verify
the email, enforce the password policy, set the new password (logout: true to
invalidate existing sessions) and issue a fresh login token.
- Add API tests for GET /v1/misc.registrationSecretCheck (valid/invalid hash,
  missing param) under the existing secret-URL registration setup.
- Changeset: hash is a query param (not a body); resetPassword is reimplemented
  server-side against Accounts, not delegated.
Seed a reset token directly in the DB (it's normally emailed), then verify the
endpoint resets the password (login with the new password succeeds), consumes
the token (reuse fails), and rejects unknown tokens / missing params.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant