From c9c1784dd7574d441a36a685b3ead31f5ec36e22 Mon Sep 17 00:00:00 2001 From: m5r Date: Tue, 24 May 2022 21:31:39 +0200 Subject: [PATCH] fix admin middleware in server.ts --- server.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.ts b/server.ts index d2796b8..c8592b9 100644 --- a/server.ts +++ b/server.ts @@ -12,7 +12,7 @@ import cronJobs from "~/cron-jobs"; import queues from "~/queues"; import logger from "~/utils/logger.server"; import { __getSession } from "~/utils/session.server"; -import { type SessionUser } from "~/utils/auth.server"; +import { type SessionData } from "~/utils/auth.server"; const app = express(); app.use((req, res, next) => { @@ -76,8 +76,8 @@ app.listen(port, () => { async function adminMiddleware(req: Request, res: Response, next: NextFunction) { const session = await __getSession(req.headers.cookie); - const user: SessionUser | undefined = session.data.user; - if (!user || user.role !== GlobalRole.SUPERADMIN) { + const sessionData: SessionData | undefined = session.data.user; + if (!sessionData || sessionData.user.role !== GlobalRole.SUPERADMIN) { return res.setHeader("Location", "/sign-in").status(302).end(); }