Skip to content

Conversation

@tiagoevanp
Copy link
Contributor

@tiagoevanp tiagoevanp commented Apr 6, 2025

Proposed changes (including videos or screenshots)

This PR introduces some new UX componentes to show the 2FA importance for users who where updated with a role that has a mandatory 2FA setting assigned.

There are also some updates changing Buttons for ToggleSwitch components.

Components:
image

image

Issue(s)

Steps to test or reproduce

Set a mandatory 2FA role for a user, deactivate any 2FA settled in the user (email or TOTP).

Further comments

CORE-971


Two Factor TOTP has a minimal change because I don't want to block this improve before release window closes. In future, some points regarding enable and disable of TOTP controll should have some refactoring. (Usage of muttations, upgrade of Meteor Method to API and so on)


This pull request focuses on improving the user experience for mandatory Two-Factor Authentication (2FA) in Rocket.Chat. Key changes include:

  1. UI Enhancements:

    • Introduced a new React hook, useRequire2faSetup, to manage UI behavior based on 2FA requirements. This hook checks if 2FA is enabled system-wide and if the user has a role requiring mandatory 2FA, while also verifying if the user has configured TOTP or Email 2FA.
    • Updated the AccountSecurityPage to conditionally manage the UI, displaying a warning callout when 2FA setup is required.
    • Refactored the TwoFactorEmail and TwoFactorTOTP components to replace separate enable/disable buttons with a ToggleSwitch, improving form structure and accessibility using Fuselage components and React's useId hook.
    • Introduced a TwoFactorRequiredModal component to inform users about the 2FA requirement, displayed via a useLayoutEffect hook.
  2. Layout Adjustments:

    • Modified the TextCopy component by replacing padding with pb (padding-bottom), which may affect layout consistency.
  3. Internationalization Updates:

    • Removed obsolete or unused translation keys related to 2FA from multiple locale files, including Afrikaans, Arabic, Azerbaijani, Belarusian, Bulgarian, Bosnian, Catalan, Czech, Welsh, Danish, German, Greek, English, Esperanto, Spanish, Persian, Finnish, French, Hindi, Croatian, Hungarian, Indonesian, Italian, Japanese, Georgian, Khmer, Korean, Kurdish, Lao, Lithuanian, Latvian, Mongolian, Malay, Norwegian, Dutch, Norwegian Nynorsk, Polish, Portuguese (Brazil), Romanian, Russian, Slovak, Slovenian, Albanian, Serbian, Swedish, Tamil, Thai, Turkish, Ukrainian, Vietnamese, Chinese (Hong Kong), Traditional Chinese, and Chinese.
    • Updated the English locale to refine language and keys related to 2FA, introducing new keys for scenarios where 2FA is required and removing older keys related to enabling/disabling TOTP or Email 2FA individually.

These changes aim to streamline the 2FA setup process, enhance user interface consistency, and clean up outdated translation strings.


This pull request focuses on improving the user experience for roles with mandatory two-factor authentication (2FA) in the Rocket.Chat application. Key changes include:

  1. User Interface Enhancements:

    • Updated the AccountSecurityPage to conditionally expand the Password or 2FA sections based on the requirement for 2FA setup, and added a warning callout for users who need to set up 2FA.
    • Refactored the TwoFactorEmail and TwoFactorTOTP components by replacing separate enable/disable buttons with a ToggleSwitch for a more streamlined user interface. These components now use Fuselage components for better form structure and accessibility improvements via React's useId hook.
  2. New Hook Introduction:

    • Introduced a useRequire2faSetup hook to determine if a user is required to set up 2FA based on their roles and global settings. This hook leverages reactive data sources and client-side role information.
  3. 2FA Setup Check Refactor:

    • Refactored the 2FA setup check in the MainLayout by using the new useRequire2faSetup hook and added a useLayoutEffect to display a TwoFactorRequiredModal when 2FA setup is necessary.
  4. Localization Updates:

    • Updated the English localization file to add and refine strings related to 2FA, including guidance for required setup and alternative methods if QR code scanning fails.
    • Removed obsolete or unused 2FA-related translation strings from multiple localization files, ensuring JSON syntax correctness by adding necessary closing braces.
  5. Component Style Adjustment:

    • Modified the TextCopy component by replacing padding with pb (padding-bottom), which may affect layout consistency.

These changes aim to enhance the 2FA setup process, improve accessibility, and clean up localization files across the application.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 6, 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 6, 2025

🦋 Changeset detected

Latest commit: 1030bc8

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

This PR includes changesets to release 37 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/i18n Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-voip Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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/model-typings 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/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

@codecov
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 75.60976% with 10 lines in your changes missing coverage. Please review.

Project coverage is 61.15%. Comparing base (3309dac) to head (1030bc8).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35709      +/-   ##
===========================================
- Coverage    61.16%   61.15%   -0.01%     
===========================================
  Files         2971     2973       +2     
  Lines        70851    70892      +41     
  Branches     16189    16216      +27     
===========================================
+ Hits         43333    43352      +19     
- Misses       24568    24592      +24     
+ Partials      2950     2948       -2     
Flag Coverage Δ
e2e 57.70% <75.60%> (+0.01%) ⬆️
unit 75.57% <ø> (ø)

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.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2025

PR Preview Action v1.6.1

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

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

@tiagoevanp tiagoevanp added this to the 7.6.0 milestone Apr 7, 2025
@ggazzo
Copy link
Member

ggazzo commented Apr 16, 2025

just saying, you need to choose, either it's a fix or an improvement. btw: mandatory for whom? I don't think this makes sense in your title, fell free to remove

looking at your images I can already tell that there's a translation missing, or the image doesn't represent your final work.

@tiagoevanp tiagoevanp marked this pull request as ready for review April 16, 2025 04:46
@tiagoevanp tiagoevanp requested a review from a team as a code owner April 16, 2025 04:46
@tiagoevanp tiagoevanp changed the title fix: Mandatory 2FA UX improvements fix: UX for roles with mandatory 2FA Apr 16, 2025
@kody-ai
Copy link

kody-ai bot commented Apr 16, 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.

4 similar comments
@kody-ai
Copy link

kody-ai bot commented Apr 16, 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.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 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.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 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.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 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.

@kody-ai
Copy link

kody-ai bot commented Apr 17, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

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.

@tiagoevanp tiagoevanp changed the title fix: UX for roles with mandatory 2FA feat: improve UX for logged users with mandatory 2FA roles Apr 17, 2025
@kody-ai
Copy link

kody-ai bot commented Apr 17, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

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.

Co-authored-by: Aleksander Nicacio da Silva <[email protected]>
@kody-ai
Copy link

kody-ai bot commented Apr 17, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

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.

@tiagoevanp tiagoevanp added the stat: QA assured Means it has been tested and approved by a company insider label Apr 17, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 17, 2025
@dionisio-bot dionisio-bot bot removed the stat: ready to merge PR tested and approved waiting for merge label Apr 18, 2025
@tiagoevanp tiagoevanp added the stat: ready to merge PR tested and approved waiting for merge label Apr 18, 2025
@kodiakhq kodiakhq bot merged commit cc344be into develop Apr 18, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the fix/mandatory_2fa branch April 18, 2025 06:48
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 stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants