FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Can anyone see why this code locks a user opposed to actually deleting the user? Version 1.20.0

    Scheduled Pinned Locked Moved
    Q&A
    0
    2
    237
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • joshuaJ
      joshua
      last edited by

      Can anyone see why this code locks a user opposed to actually deleting the user? Version 1.20.0

      public static async hardDeleteTestUser(userId: string): Promise<Response> {
          const jsonBody = {
            userId,
            hardDelete: true,
          };
          const resp = await fetch(`${process.env.FUSIONAUTH_ADDRESS}/api/user/${userId}`, {
            method: 'DELETE',
            headers: {
              'Content-Type': 'application/json',
              Authorization: process.env.FUSIONAUTH_MASTER_KEY || '',
            },
            body: JSON.stringify(jsonBody),
          });
          DEBUG &&
            Logger.debug(
              'FusionAuthService.hardDeleteTestUser',
              `Return value from fusionAuth status=${resp.status}  resp=${JSON.stringify(
                resp,
                null,
                2
              )}`,
              DEBUG
            );
          return resp;
        }
      
      1 Reply Last reply Reply Quote 0
      • joshuaJ
        joshua
        last edited by joshua

        Two issues with the code snippet that are worth exploring:

        • hardDelete is supposed to be a query param

        • Delete requests should not have body in the request.

        Find out more in the documentation for the User API

        1 Reply Last reply Reply Quote 0
        • First post
          Last post