Skip to content

Commit

Permalink
fix: fix session issue
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Mar 16, 2022
1 parent 4bf6da3 commit f05c98b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/session.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export async function getUserId(request: Request): Promise<string | undefined> {
export async function getUser(request: Request): Promise<null | User> {
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(
Expand All @@ -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({
Expand Down

0 comments on commit f05c98b

Please sign in to comment.