Skip to content

Commit

Permalink
Merge pull request #207 from huai-jie/fix-account-page
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua authored May 18, 2023
2 parents cd19eaf + 755273a commit 7d76146
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion routes/account/_middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export interface AccountState extends State {

export async function handler(
_req: Request,
ctx: MiddlewareHandlerContext<State>,
ctx: MiddlewareHandlerContext<AccountState>,
) {
const redirectResponse = redirect("/login");

if (!ctx.state.sessionId) return redirectResponse;
const user = await getUserBySessionId(ctx.state.sessionId);
if (!user) return redirectResponse;
ctx.state.user = user;
return await ctx.next();
}

0 comments on commit 7d76146

Please sign in to comment.