Thorr Stevens
Thorr Stevens

Reputation: 33

Can you manually set 'phone_number_verified' to true on an AWS Cognito user, without having the end user need to interact with your web-app?

We just solved an issue where entering a wrong phone number (starting digit was missing) resulted in 'phone_number_verified' defaulting to false. Now that the issue is resolved, we do still have a lot of registered users who have had an activation sent to them (and entered said code) whose statuses are CONFIRMED in AWS Cognito, but have the 'phone_number_verified' property still set to false. Is there any way to edit this property in bulk / per user in Cognito itself or is there an API call that needs to be made? Or any solution that does not require the end user to go through the activation process again themselves.

(Further Info)
- AngularJS as Front-End
- Node v6.9 as Back-End

Upvotes: 3

Views: 3139

Answers (2)

Siva Saketh
Siva Saketh

Reputation: 11

The phone number verified can be set to true by using the following example payload:

let parameters = { 
            UserPoolId : `${USER_POOL_ID}`,
            Username : `${Username}`,
            UserAttributes : [
                {
                    'Name': "phone_number" ,
                    'Value': `${phoneNumber}`
                },{
                    'Name':"phone_number_verified",
                    'Value': "true"
                }]
        }
        
        cognitoIdentityServiceProvider.adminUpdateUserAttributes(parameters,function (err, result) {
            if(err)
            console.log(err);
            else
            console.log("Attribute updated successfully");
        })

Upvotes: 1

Rachit Dhall
Rachit Dhall

Reputation: 1661

The recommendation here is that the users should call GetUserAttributeVerificationCode and receive a code to verify the phone/email which is then supplied to VerifyUserAttribute. This will ensure that if their numbers are verified.

Although if you are sure that all of their numbers are verified, you can use AdminUpdateUserAttributes to mark them verified. We do not have a batch API right now.

Upvotes: 4

Related Questions