[mastodon-client] Ignore invalid auth requests

This commit is contained in:
Laura Hausmann 2023-10-08 01:13:02 +02:00
parent 4d6111d1a4
commit c7d62223ef
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605

View File

@ -5,7 +5,7 @@ import { AuthConverter } from "@/server/api/mastodon/converters/auth.js";
import { MastoApiError } from "@/server/api/mastodon/middleware/catch-errors.js"; import { MastoApiError } from "@/server/api/mastodon/middleware/catch-errors.js";
export async function AuthMiddleware(ctx: MastoContext, next: () => Promise<any>) { export async function AuthMiddleware(ctx: MastoContext, next: () => Promise<any>) {
const auth = await authenticate(ctx.headers.authorization, null, true); const auth = await authenticate(ctx.headers.authorization, null, true).catch(_ => [null, null]);
ctx.user = auth[0] ?? null as ILocalUser | null; ctx.user = auth[0] ?? null as ILocalUser | null;
ctx.scopes = auth[1]?.permission ?? [] as string[]; ctx.scopes = auth[1]?.permission ?? [] as string[];