Boilerplate generator and deno tasks for monorepo
This commit is contained in:
10
middleware/auth.ts
Normal file
10
middleware/auth.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Context } from "oak";
|
||||
import { USER_TOKEN } from "../constsAndEnums.ts";
|
||||
import { verifyUserSessionToken } from "../lib/jwt.ts";
|
||||
|
||||
export const authenticateUser = async (ctx: Context, next: () => any) => {
|
||||
const jwt = await ctx.cookies.get(USER_TOKEN);
|
||||
if (!jwt) return next();
|
||||
ctx.state.user = await verifyUserSessionToken(jwt);
|
||||
await next();
|
||||
}
|
Reference in New Issue
Block a user