我在打字稿项目中有以下注册方法。
import {CognitoIdentityProviderClient, SignUpCommand} from "@aws-sdk/client-cognito-identity-provider"
const UserPoolId = *************;
const ClientId = ***********;
const region = ***********
const config = {region: region}
export const registerUser = async (req, res) => {
try {
const { username, password } = req.body;
const client = new CognitoIdentityProviderClient(config);
const command = new SignUpCommand({
ClientId: ClientId,
Username: username,
Password: password,
UserAttributes: [{ Name: "email", Value: username }],
});
const response = await client.send(command);
res.status(200).json({ message: "User Created", username: username, password: password });
}
catch (err) {
console.log("FAILED")
console.log("Error"+ err.message)
res.status(500).json({ message: "User Not Created", error: err.message});
}
};
此代码的目的是注册用户并将其添加到我在 AWS Cognito 用户池中创建的用户池中。该功能用于注册用户。我可以看到这适用于 AWS 用户池 UI。但是,用户没有通过此注册方法验证的电子邮件。当我从 AWS UI 将用户添加到用户池时,系统会自动向该用户发送一封电子邮件并验证该电子邮件。然后,必须在用户实际登录之前强制重置密码。
是否可以在此注册方法中添加该电子邮件通知?通过这样做,我应该能够让用户打开电子邮件,然后验证电子邮件。如果没有发送该电子邮件,我不确定用户如何能够验证他们的电子邮件,然后继续下一步更新他们的密码。
如有任何帮助,我们将不胜感激!