Amplify-js: Is there a way to change or update user's email using amplify from the front end?

Created on 24 Oct 2018  路  8Comments  路  Source: aws-amplify/amplify-js

* Auth *

* Cognito / MobileHub *

Using Email address to sign in... Is there a way to change or update user's email using amplify from the front end?

I don't get the flow yet.

Thanks.

Auth Cognito question

All 8 comments

I just found it: updateUserAttributes

https://aws-amplify.github.io/docs/js/authentication

@josoroma Will it update username (if I use email as username)? or it will only update value in attributes?

@Luckygirlllll did you find the answer to your question? :P

@tomaszdudek7 I used method verifyCurrentUserAttribute() , here is a link to the official documentation: https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#verifyuserattribute

@Luckygirlllll When you change a phone number or an email which is treated as a username, using updateUserAttributes, then you verify the attributes(verifyUserAttribute and then verifyUserAttributeSubmit), the username attribute does not get updated.

Pre-update:

CognitoUser {username: "+48999999999", attributes: {phone_number: "+48999999999"}

Post-update:

CognitoUser {username: "+48999999999", attributes: {phone_number: "+48123456789"}

Only after logging out and logging in again, the attribute is shown properly:

CognitoUser {username: "+48123456789", attributes: {phone_number: "+48123456789"}

I wonder how would one trigger username update after changing and veryfing the phone_number attribute.

We will try calling verifyCurrentUserAttribute instead of verifyUserAttribute, as you suggested.

@tomaszdudek7 Do you use Auth.currentUserInfo() for getting info about the user?

@Luckygirlllll Yes, attributes { phone_number are indeed refreshed. But the userName and userNameKey field (which are on the same level as attributes - one level above phone_number for example) are the same.

Only logging in and out refreshes them.

@tomaszdudek7 You can try to use this method Auth.currentAuthenticatedUser().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DougWoodCDS picture DougWoodCDS  路  3Comments

romainquellec picture romainquellec  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

ldgarcia picture ldgarcia  路  3Comments

rygo6 picture rygo6  路  3Comments