@folderharbor/sdk
    Preparing search index...

    Methods for reading, listing, and updating users and their grants.

    Constructors

    Methods

    • Creates a new user from credentials.

      Parameters

      • body: FHCreateUser

        The username and password to use for the new user

      Returns Promise<{ id: number }>

      The new user's ID

      users:create

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const { id } = await client.admin.users.create({ username: "example", password: "meow_mrrp" });
      
    • Deletes a user.

      Parameters

      • userID: number

        The user's ID

      Returns Promise<void>

      users:delete

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.users.delete(2);
      
    • Edits a user's information. This method is limited to their username, password, and clearing their failed logins.

      Parameters

      • userID: number

        The user's ID

      • body: FHEditUser

        The information to change / updates to make

      Returns Promise<void>

      users:edit

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.users.edit({ username: "meow", password: "mrrp", clearLoginAttempts: true });
      
    • Grants and revokes roles, ACLs, and permissions on a user directly.

      This is intended for if you know the current state of these values (such as in a web panel), as it does overwrite their current states. If you don't know them (such as in a CLI), see grant instead.

      Parameters

      • userID: number

        The user's ID

      • body: FHUserEditGrants

        Arrays of the role, ACL, and permission IDs to apply to the user

      Returns Promise<void>

      users:grant

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.users.editGrants(1, { roles: [1, 2], acls: [2], permissions: ["users:list", "logs:read"] });
      
    • Gets a user from their ID.

      Parameters

      • userID: number

        The user's ID

      Returns Promise<FHFullUser | FHLimitedUser>

      The user's information, either full or limited depending on your permission level

      users:read || users:read.full

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const user = await client.admin.users.get(1);
      
    • Grants and revokes roles, ACLs, and permissions on a user.

      This is intended for cases where you don't already know the current state of these values (such as in a CLI), as it does not overwrite. If you do know them (such as in a web panel), see editGrants instead.

      Parameters

      • userID: number

        The user's ID

      • body: FHGrantToUser

        An array of grantable objects using their IDs, types, and whether to grant or revoke the object

      Returns Promise<void>

      users:grant

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const grants: FHGrantToUser = [
      { id: 2, type: "role", revoke: false },
      { id: 1, type: "acl", revoke: true },
      { id: "config:read", type: "permission", revoke: true }
      ];
      await client.admin.users.grant(1, grants);
    • Gets the list of users and their IDs.

      Returns Promise<FHUserList>

      A list of users (with their usernames and IDs)

      users:list

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      const users = await client.admin.users.list();
      
    • Locks or unlocks a user's account.

      Parameters

      • userID: number

        The user's ID

      • lock: boolean

        Whether to lock or unlock the account (true = locked, false = unlocked)

      Returns Promise<void>

      users:lock

      If your session is invalid, expired, or for a locked account

      If you don't have permission to take this admin action

      If anything else went wrong, either in the process of requesting, or in the response from the server

      await client.admin.users.lock(2, true); // lock
      await client.admin.users.lock(1, false); // unlock