Skip to content
Back

`usersDelete` permissions error when deleting own account

  • 0
  • Self Hosted
  • Auth
  • GraphQL
danstevenson_reyt
20 Mar, 2024, 17:41

I am implementing an account deletion feature to allow users to delete their own account.

I have made sure to delete the associated data from the user (i.e. user profile data which is on a collection). The user is logged in and has an active session.

When requesting the userDelete process, I get a permissions error: "message": "[user's email address] (role: users) missing scope (users.write)"

How can I update user permissions to make sure users are able to delete their own account?

I have a user_profile collection, and from my appwrite.json file I have the following permissions on it: "$permissions": ["create(\"users\")", "read(\"guests\")", "update(\"users\")", "write(\"users\")"],

I don't think this is related to the user/auth permissions though. Is there a way to set user/auth permissions to users ?

This is the GraphQL query I am running:

TypeScript
const authUserDeleteResponse = await graphql.mutation({
     query: `
          mutation DeleteAuthUser(
            $userId: String!
          ) {
              usersDelete(userId: $userId) {
                status
              }
          }
        `,
                variables: {
                    userId
                }
            });
TL;DR
Developers are having permission issues when trying to delete their own accounts. The error message indicates missing scope "users.write." To resolve this, ensure that users have the necessary permission in the `appwrite.json` file for account deletion. Update the permissions to include "write(\"users\")" for user profiles. Check if the permissions are correctly set for users/auth. Verify that the user has the required permissions to delete their account.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more