-
Notifications
You must be signed in to change notification settings - Fork 13.8k
fix: UI not reflecting 2FA TOTP and email status change immediately #35185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Written code to update UI to immediately reflect 2FA status change after enabling/disabling TOTP/email | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { Box, Button, Margins } from '@rocket.chat/fuselage'; | ||
| import { useUser } from '@rocket.chat/ui-contexts'; | ||
| import type { ComponentProps } from 'react'; | ||
| import { useCallback } from 'react'; | ||
| import { useCallback, useState } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { useEndpointAction } from '../../../hooks/useEndpointAction'; | ||
|
|
@@ -10,7 +10,7 @@ const TwoFactorEmail = (props: ComponentProps<typeof Box>) => { | |
| const { t } = useTranslation(); | ||
| const user = useUser(); | ||
|
|
||
| const isEnabled = user?.services?.email2fa?.enabled; | ||
| const [isEnabled, setIsEnabled] = useState(user?.services?.email2fa?.enabled); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, can you change the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Sir. I have renamed it to |
||
|
|
||
| const enable2faAction = useEndpointAction('POST', '/v1/users.2fa.enableEmail', { | ||
| successMessage: t('Two-factor_authentication_enabled'), | ||
|
|
@@ -21,9 +21,12 @@ const TwoFactorEmail = (props: ComponentProps<typeof Box>) => { | |
|
|
||
| const handleEnable = useCallback(async () => { | ||
| await enable2faAction(); | ||
| setIsEnabled(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about to use the same technique used into TOTP file for "is enabling" state control? This will avoid any double click into the action button if a connection drop/delay happens... ;)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Sir. Thank you for the suggestion. I’ve added a If you prefer a different approach, please let me know, and I’ll make the changes accordingly |
||
| }, [enable2faAction]); | ||
|
|
||
| const handleDisable = useCallback(async () => { | ||
| await disable2faAction(); | ||
| setIsEnabled(false); | ||
| }, [disable2faAction]); | ||
|
|
||
| return ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Sir. And yes, from next time, I will write the changeset summary in the manner you mentioned.