Skip to content

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Apr 24, 2025

Proposed changes (including videos or screenshots)

This bug happened because due to a combination of three different issues in the codebase:

  • Meteor's OAuth.registerService function can only be called once per serviceName and will throw an error if its called twice, even though it doesn't do much;
  • loginServices.onLoad adds a callback to be executed when the login services are loaded from the server; It does no error handling when executing this callback and if it throws an exception, then the loginServices manager assumes that it was the loading that failed and automatically disable all login services, hiding their login buttons as well.
  • PR chore: remove meteor from oauth #35303 moved the initialization of the custom services from a Meteor.startup() function to an effect on a react hook (useCustomOAuth); If this effect gets executed twice (for example, due to a re-render), then it attempt to register the same services twice and causes meteor to throw an exception. It also doesn't remove the callbacks from prior effects when adding a new one.

The bug only happens if the AppLayout component gets re-rendered, which is not standard behavior to begin with, but I didn't look into why that was happening.

Fixing any of those issues would be enough to squash this bug, but this PR fixes all of them:

  • Automatically remove obsolete callbacks if the page gets re-rendered before the services are loaded;
  • Ignore exceptions thrown within the callback so it doesn't remove the loaded services
  • Ensure that services have not been configured yet before trying to configure them on meteor's oauth package.

Issue(s)

CORE-1153

Steps to test or reproduce

Further comments


This pull request addresses an issue with OAuth login buttons not displaying in the Rocket.Chat application. The changes include:

  1. Custom OAuth Configuration: A new mechanism is introduced in CustomOAuth.ts to manage custom OAuth service configurations on the client side. This involves adding a map (configuredOAuthServices) to store CustomOAuth instances and a static method (configureOAuthService) to update or register configurations, avoiding conflicts with existing services registered via Meteor's Accounts.oauth.

  2. Error Handling and Method Improvement: In loginServices.ts, error handling is added for emitting loaded services, and the onLoad method implementation is improved.

  3. Refactoring of useCustomOAuth Hook: The useCustomOAuth hook in useCustomOAuth.ts is refactored to utilize the static method CustomOAuth.configureOAuthService, simplifying the configuration process while maintaining the core logic of iterating through login services.

  4. Module Definition Update: A new function serviceNames is added to the oauth namespace in the accounts-base.d.ts module definition, enhancing the module without introducing security or functional concerns.

  5. Documentation: A changeset file is added to document the patch fixing the OAuth login button visibility issue.

These changes aim to resolve the visibility issue of OAuth login buttons and improve the overall configuration and error handling processes related to OAuth services.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 24, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Apr 24, 2025

🦋 Changeset detected

Latest commit: 8be347e

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

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status 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

@kody-ai
Copy link

kody-ai bot commented Apr 24, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review April 24, 2025 00:54
@pierre-lehnen-rc pierre-lehnen-rc requested a review from a team as a code owner April 24, 2025 00:54
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35864/

Built to branch gh-pages at 2025-05-05 19:05 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 9 lines in your changes missing coverage. Please review.

Project coverage is 61.28%. Comparing base (26461ca) to head (8be347e).
Report is 26 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35864      +/-   ##
===========================================
+ Coverage    61.26%   61.28%   +0.01%     
===========================================
  Files         3164     3016     -148     
  Lines        74757    71658    -3099     
  Branches     16689    16393     -296     
===========================================
- Hits         45801    43913    -1888     
+ Misses       25850    24756    -1094     
+ Partials      3106     2989     -117     
Flag Coverage Δ
e2e 58.00% <72.72%> (-0.02%) ⬇️
unit 75.11% <ø> (ø)

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.

@kody-ai
Copy link

kody-ai bot commented Apr 24, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Apr 24, 2025
@pierre-lehnen-rc pierre-lehnen-rc added this to the 7.7.0 milestone Apr 24, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 24, 2025
@kody-ai
Copy link

kody-ai bot commented Apr 24, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label May 5, 2025
@kody-ai
Copy link

kody-ai bot commented May 5, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@ggazzo ggazzo merged commit 416f42a into develop May 8, 2025
49 checks passed
@ggazzo ggazzo deleted the fix/oauth/login-button-not-showing branch May 8, 2025 23:28
ggazzo pushed a commit that referenced this pull request May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants