* 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.
I just found it: updateUserAttributes
@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().