async _persistUser(
    request,
    profileIds,
    content,
    { humanReadableId = true } = {},
  ) {
    const credentials = request.getBodyObject("credentials", {});
    const strategies = Object.keys(credentials);
    const generator = humanReadableId
      ? () => NameGenerator.generateRandomName({ prefix: "kuid" })
      : () => "kuid-" + uuidv4();

    let id = "";
    let alreadyExists = false;
    // Early checks before the user is created
    do {
      let generated = false;
      id = request.getId({
        generator: () => {
          generated = true;

          return generator();
        },
        ifMissing: "generate",
      });

      for (const strategy of strategies) {
        if (!global.kuzzle.pluginsManager.listStrategies().includes(strategy)) {
          throw kerror.get(
            "security",
            "credentials",
            "unknown_strategy",
            strategy,
          );
        }

        const exists = this.getStrategyMethod(strategy, "exists");
        alreadyExists = await exists(request, id, strategy);
        if (alreadyExists) {
          if (generated) {
            break; // exit for loop, to regenerate an id
          }

          throw kerror.get(
            "security",
            "credentials",
            "database_inconsistency",
            id,
          );
        }
      }
    } while (alreadyExists);

    const user = await this.ask(
      "core:security:user:create",
      id,
      profileIds,
      content,
      { refresh: request.getRefresh("wait_for") },
    );

    const createdUser = formatProcessing.serializeUser(user);

    // Creating credentials
    let creationFailure = null;
    const createdStrategies = [];

    for (const strategy of strategies) {
      try {
        const validate = this.getStrategyMethod(strategy, "validate");

        await validate(request, credentials[strategy], id, strategy, false);
      } catch (error) {
        creationFailure = { error, validation: true };
        break;
      }

      try {
        const create = this.getStrategyMethod(strategy, "create");

        await create(request, credentials[strategy], id, strategy);
        createdStrategies.push(strategy);
      } catch (error) {
        creationFailure = { error, validation: false };
        break;
      }
    }

    if (creationFailure === null) {
      global.kuzzle.log.info(
        `[SECURITY] ${SecurityController.userOrSdk(
          request.getKuid(),
        )} applied action "${request.input.action}" on user "${id}."`,
      );
      return createdUser;
    }

    // Failed to create credentials: rollback created strategies
    const deletionErrors = [];
    for (const strategy of createdStrategies) {
      try {
        const del = this.getStrategyMethod(strategy, "delete");
        await del(request, id, strategy);
      } catch (e) {
        // We catch any error produced by delete as we want to make as much
        // cleanup as possible
        deletionErrors.push(e);
      }
    }

    try {
      this.ask("core:security:user:delete", id, { refresh: "false" });
    } catch (e) {
      global.kuzzle.log.error(`User rollback error: ${e}`);
    }

    if (deletionErrors.length > 0) {
      // 2 errors > we
      throw kerror.get(
        "plugin",
        "runtime",
        "unexpected_error",
        [
          creationFailure.error.message,
          ...deletionErrors.map((e) => e.message),
        ].join("\n"),
      );
    }

    if (creationFailure.error instanceof KuzzleError) {
      throw creationFailure.error;
    }

    if (creationFailure.validation) {
      throw kerror.getFrom(
        creationFailure.error,
        "security",
        "credentials",
        "rejected",
        creationFailure.error.message,
      );
    }

    throw kerror.getFrom(
      creationFailure.error,
      "plugin",
      "runtime",
      "unexpected_error",
      creationFailure.error.message,
    );
  }
@param {Request} request
@returns {Promise}
@private