v3: added opengraph support to the app, wrote README instructions incl. a Docker image
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
APIException,
|
||||
type AuthPayload,
|
||||
} from "../model/interfaces.ts";
|
||||
import { getUserById } from "../services/user-service.ts";
|
||||
|
||||
export interface AuthContext extends Context {
|
||||
state: AuthState;
|
||||
@@ -32,6 +33,12 @@ export async function authMiddleware(ctx: AuthContext, next: Next) {
|
||||
throw new APIException(APIErrorCode.UNAUTHORIZED, 401, "Invalid token");
|
||||
}
|
||||
|
||||
try {
|
||||
getUserById(payload.userId);
|
||||
} catch {
|
||||
throw new APIException(APIErrorCode.UNAUTHORIZED, 401, "User not found");
|
||||
}
|
||||
|
||||
ctx.state.user = payload;
|
||||
|
||||
await next();
|
||||
|
||||
Reference in New Issue
Block a user