Send x-oasst-user header

This commit is contained in:
AbdBarho
2023-01-27 22:33:04 +01:00
parent 3a32a10b23
commit cdb9f2da4e
15 changed files with 70 additions and 44 deletions
+3 -2
View File
@@ -1,5 +1,5 @@
import { withRole } from "src/lib/auth";
import { oasstApiClient } from "src/lib/oasst_api_client";
import { createApiClient } from "src/lib/oasst_api_client";
import prisma from "src/lib/prismadb";
import { FetchUsersParams } from "src/types/Users";
@@ -17,9 +17,10 @@ const PAGE_SIZE = 20;
* - `direction`: Either "forward" or "backward" representing the pagination
* direction.
*/
const handler = withRole("admin", async (req, res) => {
const handler = withRole("admin", async (req, res, token) => {
const { cursor, direction, searchDisplayName = "", sortKey = "username" } = req.query;
const oasstApiClient = await createApiClient(token);
// First, get all the users according to the backend.
const { items: all_users, ...rest } = await oasstApiClient.fetch_users({
searchDisplayName: searchDisplayName as FetchUsersParams["searchDisplayName"],