Skip to content

Commit 3b0710f

Browse files
authored
fix(authenticator): hide Resend Code button during password-based MFA (#6961)
* fix(authenticator): hide Resend Code button during password-based MFA sign-in (#6954)
1 parent 27c8299 commit 3b0710f

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@aws-amplify/ui-react": patch
3+
---
4+
5+
fix(authenticator): hide Resend Code button during password-based MFA sign-in

packages/react/src/components/Authenticator/shared/ConfirmSignInFooter.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@ const {
1414
} = authenticatorTextUtil;
1515

1616
export const ConfirmSignInFooter = (): React.JSX.Element => {
17-
const { isPending, toSignIn, challengeName, resendCode } = useAuthenticator(
18-
(context) => [
19-
context.isPending,
20-
context.toSignIn,
21-
context.challengeName,
22-
context.resendCode,
23-
]
24-
);
17+
const {
18+
isPending,
19+
toSignIn,
20+
challengeName,
21+
resendCode,
22+
selectedAuthMethod,
23+
availableAuthMethods,
24+
} = useAuthenticator((context) => [
25+
context.isPending,
26+
context.toSignIn,
27+
context.challengeName,
28+
context.resendCode,
29+
context.selectedAuthMethod,
30+
context.availableAuthMethods,
31+
]);
2532

26-
const showResendCode = isOtpChallenge(challengeName) && resendCode;
33+
// Only show "Resend Code" for passwordless (USER_AUTH) flows.
34+
// Password-based sign-in does not support resending MFA codes.
35+
const hasPasswordlessMethod =
36+
(!!selectedAuthMethod && selectedAuthMethod !== 'PASSWORD') ||
37+
!!availableAuthMethods?.some((m) => m !== 'PASSWORD');
38+
const showResendCode =
39+
isOtpChallenge(challengeName) && hasPasswordlessMethod && resendCode;
2740

2841
return (
2942
<Flex direction="column">

0 commit comments

Comments
 (0)