I'm integrating the stripe into the MERN app. On the stripe webhook call, I need to update the user custom attributes (Cognito). Is there any possible way to find the user using email in the pool and update its custom attributes?
I have tried (function:listUsers) this code to get the user but it doesn't provide the custom variables of the user.
const params = {
UserPoolId: AWS_POOL_ID,
AttributesToGet: ["email"],
};
new Promise((resolve, reject) => {
AWS.config.update({
region: AWS_REGION,
accessKeyId: AWS_ACCESS_PUBLIC,
secretAccessKey: AWS_ACCESS_SECRET,
});
const cognitoIdentityServiceProvider =
new AWS.CognitoIdentityServiceProvider();
cognitoIdentityServiceProvider.listUsers(params, (err, data) => {
if (err) {
console.log("cognito err::", err);
reject(err);
} else {
console.log("cognito data:", data);
resolve(data);
}
});
});
Response:
[
{
Username: '15a2-c98c-43a5-63c',
Attributes: [
{ Name: 'email', Value: 'abc@gmail.com' }
],
UserCreateDate: 2021-12-02T11:33:37.561Z,
UserLastModifiedDate: 2021-12-02T11:35:24.956Z,
Enabled: true,
UserStatus: 'CONFIRMED'
},
{
Username: '15ff633f-41faa9',
Attributes: [
{ Name: 'email', Value: 'abc@gmail.com' }
],,
UserCreateDate: 2021-09-17T14:37:12.943Z,
UserLastModifiedDate: 2021-09-18T04:08:25.443Z,
Enabled: true,
UserStatus: 'CONFIRMED'
}
]
but I need to get and update the custom variables only email available for finding user