Reputation: 47
Everyone. I am developing using react app with aws amplify. For user authentication, I am using aws cognito. After I create user account by admin account on cognito, I can't change email and password of user as admin on there yet. How can I do for this?
Upvotes: 2
Views: 2172
Reputation: 488
You can do it the below way. But make sure that while configuring the cognito, the below fields[fields that you want to change] are set Mutable. Please follow these two links they might help more (Congito Attributes) & (adminUpdateUserAttributes).
var params = {
UserPoolId: '',//YOUR UserPoolID
Username: '',//username
UserAttributes: [
{
Name: "email",
Value: ``,//NEW Email
},
{
Name: "name",
Value: ``,//New Name
},
{
Name: "phone_number",
Value: ``,//New Phone
},
],
};
const cognitoClient = new AWS.CognitoIdentityServiceProvider();
var createPromise = cognitoClient.adminUpdateUserAttributes(params).promise();
await createPromise;
Upvotes: 2