From e97c1820b707965e33573a3623dc6568fdf757e5 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 16 Jun 2026 03:33:11 +0200 Subject: [PATCH] Fix import --- src/api/middlewares/Authentication.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api/middlewares/Authentication.ts b/src/api/middlewares/Authentication.ts index 9e2fa8173..9b14a4ae9 100644 --- a/src/api/middlewares/Authentication.ts +++ b/src/api/middlewares/Authentication.ts @@ -19,6 +19,7 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server/HTTPError"; import { Session, User } from "@spacebar/database"; +import { Random } from "@spacebar/extensions"; import { checkToken, Rights, UserTokenData } from "@spacebar/util"; export const NO_AUTHORIZATION_ROUTES = [ @@ -89,8 +90,11 @@ export async function Authentication(req: Request, res: Response, next: NextFunc .split("; ") .find((x) => x.startsWith("__sb_sessid="))! .split("=")[1]; - // for some reason we need to require here, else the openapi generator fails with "route is not a function" - else res.setHeader("Set-Cookie", `__sb_sessid=${(req.fingerprint = (await require("../util")).randomString(32))}; Secure; HttpOnly; SameSite=None; Path=/`); + else + res.setHeader( + "Set-Cookie", + `__sb_sessid=${(req.fingerprint = Random.getString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 32))}; Secure; HttpOnly; SameSite=None; Path=/`, + ); if ( NO_AUTHORIZATION_ROUTES.some((x) => {