Skip to content

Commit

Permalink
More error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshschuler committed May 30, 2023
1 parent 68dfbbe commit f836b72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/src/middleware/auth.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,21 @@ export async function validateAccessToken(ctx: RouterContext<string>, next: () =
return;
}

let errorMessage = "No access token found in session.";
const storedAccessToken: string = await ctx.state.session.get("accessToken");
if (!isNullOrUndefined(storedAccessToken)) {
const result = await compareValues(accessToken!, storedAccessToken);
if (result) {
await next();
return;
} else {
errorMessage = "Access Tokens don't match";
}
}

await logError(errorMessage, ctx.state.session);
await ctx.state.session.deleteSession();

await logError("No access token found in session.");

handleErrorResponse(ctx, null, Status.Unauthorized);
}

Expand Down

0 comments on commit f836b72

Please sign in to comment.