aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers/apiKeys.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-13 01:11:14 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-13 01:11:14 +0000
commitf8ae986692f82efe8c1f3940907aab553e4f5a49 (patch)
tree5180fb18a644c743bc26a3c78620b59489f4e209 /packages/trpc/routers/apiKeys.ts
parent360ef9dbbe68f2b87fcb59ff0100de7527cc88ba (diff)
downloadkarakeep-f8ae986692f82efe8c1f3940907aab553e4f5a49.tar.zst
fix: Drop auth failure logger
Diffstat (limited to 'packages/trpc/routers/apiKeys.ts')
-rw-r--r--packages/trpc/routers/apiKeys.ts29
1 files changed, 8 insertions, 21 deletions
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("<unknown>", error.message, ctx.req.ip);
- throw e;
- }
+ .mutation(async ({ input }) => {
+ await authenticateApiKey(input.apiKey); // Throws if the key is invalid
+ return {
+ success: true,
+ };
}),
});