aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers/apiKeys.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-07-21 00:33:33 +0000
committerMohamed Bassem <me@mbassem.com>2025-07-21 00:33:33 +0000
commitbb11907e8b04d519c4ea3e67d4c7ce5a6226914b (patch)
tree4dd81c88aad12ee9b6db2a81e0190baac56a6b31 /packages/trpc/routers/apiKeys.ts
parent52ac0869d53b54e91db557f012f7ee9a3ecc3e9d (diff)
downloadkarakeep-bb11907e8b04d519c4ea3e67d4c7ce5a6226914b.tar.zst
fix: Remove bcrypt from the api key validation route
Diffstat (limited to 'packages/trpc/routers/apiKeys.ts')
-rw-r--r--packages/trpc/routers/apiKeys.ts12
1 files changed, 6 insertions, 6 deletions
diff --git a/packages/trpc/routers/apiKeys.ts b/packages/trpc/routers/apiKeys.ts
index a7a7ad09..b7d11d41 100644
--- a/packages/trpc/routers/apiKeys.ts
+++ b/packages/trpc/routers/apiKeys.ts
@@ -29,7 +29,7 @@ export const apiKeysAppRouter = router({
)
.output(zApiKeySchema)
.mutation(async ({ input, ctx }) => {
- return await generateApiKey(input.name, ctx.user.id);
+ return await generateApiKey(input.name, ctx.user.id, ctx.db);
}),
revoke: authedProcedure
.input(
@@ -85,7 +85,7 @@ export const apiKeysAppRouter = router({
}),
)
.output(zApiKeySchema)
- .mutation(async ({ input }) => {
+ .mutation(async ({ input, ctx }) => {
let user;
// Special handling as otherwise the extension would show "username or password is wrong"
if (serverConfig.auth.disablePasswordAuth) {
@@ -95,11 +95,11 @@ export const apiKeysAppRouter = router({
});
}
try {
- user = await validatePassword(input.email, input.password);
+ user = await validatePassword(input.email, input.password, ctx.db);
} catch {
throw new TRPCError({ code: "UNAUTHORIZED" });
}
- return await generateApiKey(input.keyName, user.id);
+ return await generateApiKey(input.keyName, user.id, ctx.db);
}),
validate: publicProcedure
.use(
@@ -111,8 +111,8 @@ export const apiKeysAppRouter = router({
) // 30 requests per minute
.input(z.object({ apiKey: z.string() }))
.output(z.object({ success: z.boolean() }))
- .mutation(async ({ input }) => {
- await authenticateApiKey(input.apiKey); // Throws if the key is invalid
+ .mutation(async ({ input, ctx }) => {
+ await authenticateApiKey(input.apiKey, ctx.db); // Throws if the key is invalid
return {
success: true,
};