diff --git a/docs/guides/authentication/fragments/js/managing-user-attributes.md b/docs/guides/authentication/fragments/js/managing-user-attributes.md index ad479e8cde1..9a03ebc404d 100644 --- a/docs/guides/authentication/fragments/js/managing-user-attributes.md +++ b/docs/guides/authentication/fragments/js/managing-user-attributes.md @@ -56,6 +56,15 @@ async function updateUser() { } ``` +You can also use the `deleteUserAttributes` method of the __Auth__ class to delete user attributes: + +```js +async function updateUser() { + const user = await Auth.currentAuthenticatedUser(); + await Auth.deleteUserAttributes(user, ['address']); +} +``` + ### Reading user attributes To read user attributes, you can use the `currentAuthenticatedUser` method of the Auth class: @@ -107,4 +116,15 @@ async function updateUser() { 'custom:favorite_ice_cream': 'vanilla' }); } +``` + +You can also use the `deleteUserAttributes` method of the __Auth__ class to delete custom user attributes: + +```js +async function updateUser() { + const user = await Auth.currentAuthenticatedUser(); + await Auth.deleteUserAttributes(user, [ + 'custom:favorite_ice_cream' + ]); +} ``` \ No newline at end of file diff --git a/docs/lib/auth/fragments/js/manageusers.md b/docs/lib/auth/fragments/js/manageusers.md index f1bfc16e0f1..182ed3d5451 100644 --- a/docs/lib/auth/fragments/js/manageusers.md +++ b/docs/lib/auth/fragments/js/manageusers.md @@ -161,6 +161,17 @@ let result = await Auth.updateUserAttributes(user, { console.log(result); // SUCCESS ``` +You can delete user attributes: + +```javascript +let user = await Auth.currentAuthenticatedUser(); + +let result = await Auth.deleteUserAttributes(user, [ + 'family_name' +]); +console.log(result); // SUCCESS +``` + > You can find a list of all custom attributes here. If you change the email address, the user will receive a confirmation code. In your app, you can confirm the verification code: