Skip to content

fix: clean up OAuth tokens after user deactivation#40633

Open
dionisio-bot[bot] wants to merge 1 commit into
release-7.10.12from
backport-7.10.12-40524
Open

fix: clean up OAuth tokens after user deactivation#40633
dionisio-bot[bot] wants to merge 1 commit into
release-7.10.12from
backport-7.10.12-40524

Conversation

@dionisio-bot
Copy link
Copy Markdown
Contributor

@dionisio-bot dionisio-bot Bot commented May 20, 2026

Backport of #40524

@dionisio-bot dionisio-bot Bot requested review from a team as code owners May 20, 2026 21:26
@dionisio-bot dionisio-bot Bot requested a review from julio-rocketchat May 20, 2026 21:26
@dionisio-bot dionisio-bot Bot added the backport Used to inform backported PR label May 20, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

🦋 Changeset detected

Latest commit: 3a524d4

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

This PR includes changesets to release 5 packages
Name Type
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

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

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

1 issue found across 12 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/app/api/server/v1/users.ts">

<violation number="1" location="apps/meteor/app/api/server/v1/users.ts:429">
P1: OAuth tokens are deleted using a stale pre-update user list, so active users can lose tokens under concurrent activity.</violation>
</file>

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

Re-trigger cubic


const { modifiedCount: count } = await Users.setActiveNotLoggedInAfterWithRole(lastLoggedIn, role, false);

await Promise.all([
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.

P1: OAuth tokens are deleted using a stale pre-update user list, so active users can lose tokens under concurrent activity.

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

<comment>OAuth tokens are deleted using a stale pre-update user list, so active users can lose tokens under concurrent activity.</comment>

<file context>
@@ -426,6 +426,12 @@ API.v1.addRoute(
 
 			const { modifiedCount: count } = await Users.setActiveNotLoggedInAfterWithRole(lastLoggedIn, role, false);
 
+			await Promise.all([
+				OAuthAccessTokens.deleteByUserIds(ids),
+				OAuthRefreshTokens.deleteByUserIds(ids),
</file context>

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-7.10.12@e2d618a). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##             release-7.10.12   #40633   +/-   ##
==================================================
  Coverage                   ?   66.28%           
==================================================
  Files                      ?     3311           
  Lines                      ?   111271           
  Branches                   ?    21058           
==================================================
  Hits                       ?    73753           
  Misses                     ?    34778           
  Partials                   ?     2740           
Flag Coverage Δ
e2e 57.46% <ø> (?)
unit 71.49% <ø> (?)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Used to inform backported PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant