From f8ae986692f82efe8c1f3940907aab553e4f5a49 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 13 Jul 2025 01:11:14 +0000 Subject: fix: Drop auth failure logger --- packages/trpc/routers/apiKeys.ts | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'packages/trpc/routers/apiKeys.ts') diff --git a/packages/trpc/routers/apiKeys.ts b/packages/trpc/routers/apiKeys.ts index d4e01aa5..a7a7ad09 100644 --- a/packages/trpc/routers/apiKeys.ts +++ b/packages/trpc/routers/apiKeys.ts @@ -5,12 +5,7 @@ import { z } from "zod"; import { apiKeys } from "@karakeep/db/schema"; import serverConfig from "@karakeep/shared/config"; -import { - authenticateApiKey, - generateApiKey, - logAuthenticationError, - validatePassword, -} from "../auth"; +import { authenticateApiKey, generateApiKey, validatePassword } from "../auth"; import { authedProcedure, createRateLimitMiddleware, @@ -90,7 +85,7 @@ export const apiKeysAppRouter = router({ }), ) .output(zApiKeySchema) - .mutation(async ({ input, ctx }) => { + .mutation(async ({ input }) => { let user; // Special handling as otherwise the extension would show "username or password is wrong" if (serverConfig.auth.disablePasswordAuth) { @@ -101,9 +96,7 @@ export const apiKeysAppRouter = router({ } try { user = await validatePassword(input.email, input.password); - } catch (e) { - const error = e as Error; - logAuthenticationError(input.email, error.message, ctx.req.ip); + } catch { throw new TRPCError({ code: "UNAUTHORIZED" }); } return await generateApiKey(input.keyName, user.id); @@ -118,16 +111,10 @@ export const apiKeysAppRouter = router({ ) // 30 requests per minute .input(z.object({ apiKey: z.string() })) .output(z.object({ success: z.boolean() })) - .mutation(async ({ input, ctx }) => { - try { - await authenticateApiKey(input.apiKey); // Throws if the key is invalid - return { - success: true, - }; - } catch (e) { - const error = e as Error; - logAuthenticationError("", error.message, ctx.req.ip); - throw e; - } + .mutation(async ({ input }) => { + await authenticateApiKey(input.apiKey); // Throws if the key is invalid + return { + success: true, + }; }), }); -- cgit v1.2.3-70-g09d2