fix: Login form GUI crash after closing 2FA modal (#31625)

Co-authored-by: Henrique Guimarães Ribeiro <43561537+rique223@users.noreply.github.com>
pull/31595/head^2
Abhi Patel 2 years ago committed by GitHub
parent a21ae01918
commit f612d741f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/tall-bears-compete.md
  2. 7
      packages/web-ui-registration/src/LoginForm.tsx

@ -0,0 +1,5 @@
---
"@rocket.chat/web-ui-registration": patch
---
Fixed a bug that caused the Login page to crash when closing the Two-Factor Authentication modal using the Cancel button or the X button.

@ -56,7 +56,7 @@ const LOGIN_SUBMIT_ERRORS = {
},
} as const;
export type LoginErrors = keyof typeof LOGIN_SUBMIT_ERRORS;
export type LoginErrors = keyof typeof LOGIN_SUBMIT_ERRORS | 'totp-canceled';
export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRouter }): ReactElement => {
const {
@ -111,7 +111,12 @@ export const LoginForm = ({ setLoginRoute }: { setLoginRoute: DispatchLoginRoute
}, [errorOnSubmit]);
const renderErrorOnSubmit = (error: LoginErrors) => {
if (error === 'totp-canceled') {
return null;
}
const { type, i18n } = LOGIN_SUBMIT_ERRORS[error];
return (
<Callout id={`${usernameId}-error`} aria-live='assertive' type={type}>
{t(i18n)}

Loading…
Cancel
Save