Amplify-js: Not able to verify user attributes for an authenticated user.

Created on 26 Feb 2018  路  12Comments  路  Source: aws-amplify/amplify-js

i am getting the typescript error while using this code:
Code
cognitoUser.getAttributeVerificationCode(mobileNo, { onSuccess: function (result) { console.log('call result: ' + result); }, onFailure: function (err) { alert(err); }, inputVerificationCode: function () { var verificationCode = prompt('Please input verification code: ', ''); cognitoUser.verifyAttribute('phone_number', verificationCode, this); } });
Error
[ts]
Argument of type '{ onSuccess: (result: any) => void; onFailure: (err: Error) => void; inputVerificationCode: () =>...' is not assignable to parameter of type '{ onSuccess: () => void; onFailure: (err: Error) => void; inputVerificationCode: (data: string) =...'.
Types of property 'onSuccess' are incompatible.
Type '(result: any) => void' is not assignable to type '() => void'.

Auth feature-request

Most helpful comment

Amplify Auth has the methods to verify user attributes

To get a code:

Auth.verifyCurrentUserAttribute('phone_number')

To submit a code:

Auth.verifyCurrentUserAttributeSubmit('phone_number', code)

All 12 comments

Any support for this issue ??

Any support for this issue ??

Hi @Nitansh44, I am not entirely sure about this typescript issue. It works well for me in JS code. It seems your callbacks are not defined correctly.

In my case while signup I am giving both, email and mobile number for registration and I want to verify both of them as well but but I am receiving verification code only for the mobile number not for the email. But when I remove mobile number from signup then I'll starting getting code/link for email verification. Is it the actual behaviour that user pool will give preference to mobile number over email for verification, or if I am missing something.

Yes @Nitansh44, your situation is exactly expected. User pool will preference to mobile number over email for verification.

Then how should I verify the email also ?

Hi @Nitansh44, you can call GetUserAttributeVerificationCode API to get verification code (https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_GetUserAttributeVerificationCode.html ) and then call VerifyUserAttribute API to verify it. (https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_VerifyUserAttribute.html)

Amplify Auth has the methods to verify user attributes

To get a code:

Auth.verifyCurrentUserAttribute('phone_number')

To submit a code:

Auth.verifyCurrentUserAttributeSubmit('phone_number', code)

do anyone know how to set any other country for phone numbers in aws amplify.

@Nitansh44 Closing the issue. You can verify the phone or email by: https://aws-amplify.github.io/docs/js/authentication#verify-phone_number-or-email-address

If you still have this issue please feel free to reopen it.

Hi, @powerful23 , how would I post-authenticate verify an email in this situation use the email link method? I have tried generating a custom email message using the https://.auth.us-east-2.amazoncognito.com/confirmUser call but this gives me an error saying the user is already confirmed. is there a way to confirm a userAttribute like email through a link or is sending the code through the app my only option?

@jeffjvick This question was never answered, but I would like to do the same ^^^

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josoroma picture josoroma  路  3Comments

guanzo picture guanzo  路  3Comments

romainquellec picture romainquellec  路  3Comments

DougWoodCDS picture DougWoodCDS  路  3Comments

ddemoll picture ddemoll  路  3Comments