fix: api keys authentication does not work #1511 (#1512)

* fix: api keys authentication does not work #1511

* chore: add ip and user-agent to logs of unauthenticated api-keys
This commit is contained in:
Meier Lukas authored and GitHub committed 2024-11-20 21:55:04 +01:00
1 parent a2a65abd3d
commit 72eda1f225
3 files changed
+38 -11

No files matched your search

+3 -2
View File
@@ -28,14 +28,15 @@ export const apiKeysRouter = createTRPCRouter({
const salt = await createSaltAsync();
const randomToken = generateSecureRandomToken(64);
const hashedRandomToken = await hashPasswordAsync(randomToken, salt);
const id = createId();
await db.insert(apiKeys).values({
id: createId(),
id,
apiKey: hashedRandomToken,
salt,
userId: ctx.session.user.id,
});
return {
randomToken,
apiKey: `${id}.${randomToken}`,
};
}),
});