diff --git a/src/directory/directory.mjs b/src/directory/directory.mjs index 20fba922263..41f26b3b4b1 100644 --- a/src/directory/directory.mjs +++ b/src/directory/directory.mjs @@ -203,7 +203,7 @@ export const directory = { filters: ['flutter'] }, { - title: 'Delete user', + title: 'Delete user account', route: '/lib/auth/delete_user', filters: ['android', 'flutter', 'ios', 'js', 'react-native'] }, diff --git a/src/pages/lib/auth/delete_user/q/platform/[platform].mdx b/src/pages/lib/auth/delete_user/q/platform/[platform].mdx index 366be934692..34d94b1e191 100644 --- a/src/pages/lib/auth/delete_user/q/platform/[platform].mdx +++ b/src/pages/lib/auth/delete_user/q/platform/[platform].mdx @@ -1,6 +1,6 @@ export const meta = { - title: `Delete user`, - description: `Delete a user`, + title: `Delete user account`, + description: `Learn how to delete a user account.`, filterKey: 'platform', supportedPlatforms: INTEGRATION_FILTER_OPTIONS }; @@ -22,21 +22,95 @@ export const getStaticProps = (context) => { }; }; -import ios0 from '/src/fragments/lib/auth/native_common/delete_user/common.mdx'; + - +Empowering users to delete their account can improve trust and transparency. You can programmatically enable self-service account deletion with Amplify Auth. In this guide, we will review how you can enable this feature for your users. -import flutter1 from '/src/fragments/lib/auth/native_common/delete_user/common.mdx'; +Before you begin, you will need: +- An Amplify project with the Auth category configured +- The Amplify Libraries installed and configured +- A test user to delete - +## Allow my users to delete their account + +You can quickly set up account deletion for your users with the Amplify Libraries. Invoking the `deleteUser` API to delete a user from the Auth category will also sign out your user. + +If your application uses a Cognito User Pool, which is the default configuration, this action will only delete the user from the Cognito User Pool. It will have no effect if you are federating with a Cognito Identity Pool alone. + + + + Before invoking the `deleteUser` API, you may need to first delete associated user data that is not stored in Cognito. For example, if you are using Amplify GraphQL API to persist user data, you could follow [these instructions](https://gist.github.com/aws-amplify-ops/27954c421bd72930874d48c15c284807) to delete associated user data. This allows you to address any guidelines (such as GDPR) that require your app to delete data associated with a user who deletes their account. + + + +You can enable account deletion using the following method: + + + + +```ts +import { Auth } from 'aws-amplify'; + +async function deleteUser() { + try { + const result = await Auth.deleteUser(); + console.log(result); + } catch (error) { + console.log('Error deleting user', error); + } +} +``` + + + +```js +import { Auth } from 'aws-amplify'; + +async function deleteUser() { + try { + const result = await Auth.deleteUser(); + console.log(result); + } catch (error) { + console.log('Error deleting user', error); + } +} +``` + + + +We recommend you update your UI to let your users know that their account is deleted and test the functionality with a test user. Note that your user will be signed out of your application when they delete their account. -import javascript2 from '/src/fragments/lib/auth/js/delete_user.mdx'; +## Conclusion - +Congratulations! You finished the **Delete user account** guide. In this guide, you learned how to enable account deletion for your users. -import reactnative0 from '/src/fragments/lib/auth/js/delete_user.mdx'; +## Next steps - +Now that you enabled account deletion you may also want to add some additional features. We recommend you learn more about: + + + +- [Manage user profile](/lib/auth/manageusers/q/platform/js/) +- [Set up password change and recovery](/lib/auth/password_management/q/platform/js/) + + + + + +- [Manage user profile](/lib/auth/manageusers/q/platform/react-native/) +- [Set up password change and recovery](/lib/auth/password_management/q/platform/react-native/) + + + + + +import ios0 from '/src/fragments/lib/auth/native_common/delete_user/common.mdx'; + + + +import flutter1 from '/src/fragments/lib/auth/native_common/delete_user/common.mdx'; + + import android3 from '/src/fragments/lib/auth/native_common/delete_user/common.mdx';