3개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
Yes, you can activate the "Allow Cognito to automatically send messages to verify and confirm" feature using the AWS CDK for your Cognito UserPool.
To enable the email verification in a Cognito UserPool using the AWS CDK in JavaScript, you should configure the autoVerifiedAttributes property and set up the email configuration for the UserPool.
const cdk = require('@aws-cdk/core');
const cognito = require('@aws-cdk/aws-cognito');
class CognitoStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props);
new cognito.UserPool(this, 'MyUserPool', {
// Specify that email addresses are an account identifier and are auto-verified.
signInAliases: {
email: true
},
autoVerifiedAttributes: [cognito.UserPoolAttribute.EMAIL],
// Email configuration
email: {
from: 'noreply@yourdomain.com', // replace with your "from" address
replyTo: 'support@yourdomain.com' // replace with your "reply to" address
},
// ... (other UserPool configurations if any)
});
}
}
const app = new cdk.App();
new CognitoStack(app, 'CognitoStack');
Regards, Andrii
0
Hi Andrii, Thank you for your answer. I guess your code is using the CDK version 1. I migrate to version 2 because it is said v1 is no longuer maintained :(
Here is my V2 code and I can't find any attribute like autoVerifiedAttributes:
const userPool = new UserPool(stack, "UserPool.Passwordless.Create", {
removalPolicy: RemovalPolicy.RETAIN,
userPoolName: `CGC-UserPool-Passwordless-${branchID}`,
selfSignUpEnabled: true,
autoVerify: {
email: false,
},
signInAliases: {
email: true,
},
userVerification: {
emailSubject: "Votre lien de vérification ....",
emailBody: "Bonjour, ... {##Verify Email##}.",
emailStyle: VerificationEmailStyle.LINK,
},
standardAttributes: {
email: {
required: true,
mutable: false,
},
nickname: {
required: true,
mutable: false,
},
},
});
userPool.addDomain("UserPoolDomain.Passwordless.Create", {
cognitoDomain: {
domainPrefix: "cgc-signup",
},
});
답변함 7달 전
관련 콘텐츠
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 2년 전
- AWS 공식업데이트됨 일 년 전
- AWS 공식업데이트됨 2년 전
Damn, I used this config some days ago and maybe I did something wrong that day. Thank you so much it's perfect.