diff --git a/.changeset/chatty-fishes-peel.md b/.changeset/chatty-fishes-peel.md new file mode 100644 index 00000000000..6362a219b8c --- /dev/null +++ b/.changeset/chatty-fishes-peel.md @@ -0,0 +1,5 @@ +--- +"@wso2is/myaccount": minor +--- + +Remove the implementation of showing the old qr code diff --git a/apps/myaccount/src/components/multi-factor-authentication/authenticators/totp-authenticator.tsx b/apps/myaccount/src/components/multi-factor-authentication/authenticators/totp-authenticator.tsx index 0f387cc779c..8d960fc781d 100644 --- a/apps/myaccount/src/components/multi-factor-authentication/authenticators/totp-authenticator.tsx +++ b/apps/myaccount/src/components/multi-factor-authentication/authenticators/totp-authenticator.tsx @@ -19,7 +19,7 @@ import { TestableComponentInterface } from "@wso2is/core/models"; import { GenericIcon, LinkButton, Popup } from "@wso2is/react-components"; import QRCode from "qrcode.react"; -import React, { FormEvent, PropsWithChildren, SyntheticEvent, useEffect, useRef, useState } from "react"; +import React, { PropsWithChildren, ReactElement, SyntheticEvent, useEffect, useRef, useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; import { @@ -41,11 +41,9 @@ import { initTOTPCode, refreshTOTPCode, updateEnabledAuthenticators, - validateTOTPCode, - viewTOTPCode + validateTOTPCode } from "../../../api"; import { getMFAIcons } from "../../../configs"; -import { commonConfig } from "../../../extensions"; import { AlertInterface, AlertLevels, @@ -103,8 +101,8 @@ export const TOTPAuthenticator: React.FunctionComponent = ( const [ isTOTPError, setIsTOTPError ] = useState(false); const [ isRevokeTOTPModalOpen, setIsRevokeTOTPModalOpen ] = useState(false); const [ isViewTOTPModalOpen, setIsViewTOTPModalOpen ] = useState(false); + const [ isConfirmRegenerationModalOpen, setIsConfirmRegenerationModalOpen ] = useState(false); const [ viewTOTPModalCurrentStep, setViewTOTPModalCurrentStep ] = useState(0); - const [ isConfirmRegenerate, setIsConfirmRegenerate ] = useState(false); const pinCode1: React.MutableRefObject = useRef(); const pinCode2: React.MutableRefObject = useRef(); @@ -654,39 +652,6 @@ export const TOTPAuthenticator: React.FunctionComponent = ( ); }; - /** - * Handle view TOTP event. - */ - const handleViewTOTP = (): void => { - setIsLoading(true); - viewTOTPCode() - .then((response: any) => { - const qrCodeUrl: string = window.atob(response?.data?.qrCodeUrl); - - setQrCode(qrCodeUrl); - setIsViewTOTPModalOpen(true); - }) - .catch((error: any) => { - onAlertFired({ - description: t(translateKey + "notifications.initError.error.description", { - error - }), - level: AlertLevels.ERROR, - message: t(translateKey + "notifications.initError.error.message") - }); - }) - .finally(() => { - setIsLoading(false); - }); - }; - - /** - * Handle confirm QR code regeneration checkbox event. - */ - const handleConfirmRegenerateQRCode = (_: FormEvent, data: CheckboxProps): void => { - setIsConfirmRegenerate(data.checked ?? false); - }; - /** * Handle regenerate QR code event. */ @@ -697,6 +662,8 @@ export const TOTPAuthenticator: React.FunctionComponent = ( const qrCodeUrl: string = window.atob(response?.data?.qrCodeUrl); setQrCode(qrCodeUrl); + setIsViewTOTPModalOpen(true); + setIsConfirmRegenerationModalOpen(false); setViewTOTPModalCurrentStep(1); }) .catch((errorMessage: any) => { @@ -713,6 +680,48 @@ export const TOTPAuthenticator: React.FunctionComponent = ( }); }; + /** + * Render the totp QR code regenerate confirmation modal + */ + const renderConfirmRegenerateModal = (): ReactElement => { + + + +

{ t(translateKey + "modals.scan.regenerateConfirmLabel") }

+
+ + + + { t(translateKey + "modals.scan.regenerateWarning.generic") } + + +
+ + setIsConfirmRegenerationModalOpen(false) } + data-testid={ `${testId}-regenerate-confirm-modal-actions-cancel-button` } + > + { t("common:cancel") } + + + +
+ ); + }; + /** * Renders modal content. * @@ -724,59 +733,15 @@ export const TOTPAuthenticator: React.FunctionComponent = ( return (
{ t(translateKey + "modals.scan.heading") }
- - { qrCode - ? - : null - } -
- - - - { t(commonConfig.accountSecurityPage.mfa.totp.regenerateWarning) } - - - { - commonConfig.accountSecurityPage.mfa.totp.showRegenerateConfirmation - ? ( - - ) : null - } -
- - - - - -