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.

fix: not returning from middleware

Andrej Acevskib71f4c6adb3b
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index b03214bd3..2cc8f8750 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -38,19 +38,18 @@ const app = new Elysia()
async beforeHandle({ store, cookie: { session }, set }) {
if (isDemoMode) {
if (!session?.value) {
- return await setDemoUser(set);
+ await setDemoUser(set);
}
const { user, session: validatedSession } = await validateSessionToken(
- session.value,
+ session.value ?? "",
);
if (!user || !validatedSession) {
- return await setDemoUser(set);
+ await setDemoUser(set);
}
- store.userEmail = user.email;
- return { user };
+ store.userEmail = user?.email ?? "";
}
if (!session?.value) {
diff --git a/apps/api/src/utils/set-demo-user.ts b/apps/api/src/utils/set-demo-user.ts
index 9fad7af97..f74cb31bc 100644
--- a/apps/api/src/utils/set-demo-user.ts
+++ b/apps/api/src/utils/set-demo-user.ts
@@ -4,13 +4,8 @@ import { createDemoUser } from "./create-demo-user";
async function setDemoUser(set: { cookie?: Record<string, ElysiaCookie> }) {
const demoExpiresAt = new Date(Date.now() + 15 * 60 * 1000);
- const {
- id,
- name,
- email,
- session: demoSession,
- expiresAt = demoExpiresAt,
- } = await createDemoUser();
+ const { session: demoSession, expiresAt = demoExpiresAt } =
+ await createDemoUser();
set.cookie = {
session: {
@@ -22,14 +17,6 @@ async function setDemoUser(set: { cookie?: Record<string, ElysiaCookie> }) {
expires: expiresAt,
},
};
-
- return {
- user: {
- id,
- name,
- email,
- },
- };
}
export default setDemoUser;