Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: add admin authentication and enhance task comment event with user details

Andrej Acevski6e08df906b05
diff --git a/apps/api/src/activity/index.ts b/apps/api/src/activity/index.ts
index ab26b626d..4f9ae059a 100644
--- a/apps/api/src/activity/index.ts
+++ b/apps/api/src/activity/index.ts
@@ -2,6 +2,7 @@ import { eq } from "drizzle-orm";
import { Hono } from "hono";
import { describeRoute, resolver, validator } from "hono-openapi";
import * as v from "valibot";
+import { auth } from "../auth";
import db from "../database";
import { taskTable } from "../database/schema";
import { publishEvent, subscribeToEvent } from "../events";
@@ -99,6 +100,7 @@ const activity = new Hono<{
const { taskId, comment } = c.req.valid("json");
const userId = c.get("userId");
const newComment = await createComment(taskId, userId, comment);
+ const user = await auth.api.getUser({ query: { id: userId } });
const [task] = await db
.select({ projectId: taskTable.projectId })
@@ -109,7 +111,7 @@ const activity = new Hono<{
await publishEvent("task.comment_created", {
taskId,
userId,
- comment,
+ comment: `"${user?.name}" commented: ${comment}`,
projectId: task.projectId,
});
}
diff --git a/apps/api/src/auth.ts b/apps/api/src/auth.ts
index 13bad8f1a..6811be88e 100644
--- a/apps/api/src/auth.ts
+++ b/apps/api/src/auth.ts
@@ -8,6 +8,7 @@ import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { APIError } from "better-auth/api";
import {
+ admin,
anonymous,
apiKey,
createAuthMiddleware,
@@ -240,6 +241,7 @@ export const auth = betterAuth({
],
}),
apiKey(),
+ admin(),
],
session: {
cookieCache: {