aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/routers/apiKeys.ts
diff options
context:
space:
mode:
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,
};