From f05c98b04f03933fa77621e2a1ee1dc0145b2991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 16 Mar 2022 17:30:29 +0100 Subject: [PATCH] fix: fix session issue --- app/session.server.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/session.server.ts b/app/session.server.ts index 1e67ca9..9f23399 100644 --- a/app/session.server.ts +++ b/app/session.server.ts @@ -34,7 +34,11 @@ export async function getUserId(request: Request): Promise { export async function getUser(request: Request): Promise { const userId = await getUserId(request); if (userId === undefined) return null; - return getUserById(userId); + + const user = await getUserById(userId); + if (user) return user; + + throw await logout(request); } export async function requireUserId( @@ -51,7 +55,11 @@ export async function requireUserId( export async function requireUser(request: Request) { const userId = await requireUserId(request); - return getUserById(userId); + + const user = await getUserById(userId); + if (user) return user; + + throw await logout(request); } export async function createUserSession({