feat(cognito): support email based MFA#31816
Conversation
ffccc0c to
1161629
Compare
| } | ||
| if (props.mfaSecondFactor!.otp) { | ||
| enabledMfas.push('SOFTWARE_TOKEN_MFA'); | ||
| } if (props.mfaSecondFactor!.email) { |
There was a problem hiding this comment.
An idea to make this code more readable - we could add a helper function to validate email MFA, something like:
function validateEmailMfa(props: UserPoolProps) {
if (!props.email || this.emailConfiguration?.emailSendingAccount !== 'DEVELOPER') {
throw new Error('To enable email-based MFA, set `email` property to the Amazon SES email-sending configuration.');
}
if (props.advancedSecurityMode === AdvancedSecurityMode.OFF) {
throw new Error('To enable email-based MFA, set `advancedSecurityMode` to `AdvancedSecurity.ENFORCED` or `AdvancedSecurity.AUDIT`.');
}
}and then replace the if statements with:
if (props.mfaSecondFactor!.otp) {
enabledMfas.push('SOFTWARE_TOKEN_MFA');
}
if (props.mfaSecondFactor!.email) {
validateEmailMfa(props);
enabledMfas.push('EMAIL_OTP');
}Makes it easier to follow this code
There was a problem hiding this comment.
Thanks. I've updated.
I thought private methods would be better so I went with that approach.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
@Mergifyio update |
❌ Mergify doesn't have permission to updateDetailsFor security reasons, Mergify can't update this pull request. Try updating locally. |
Pull request has been modified.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #31815.
Reason for this change
To use email based MFA.
Description of changes
Add email option to MfaSecondFactor.
Description of how you validated changes
Add unit tests and integ test.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license