From bedba3220c02a7be596687223139e6a6274513b3 Mon Sep 17 00:00:00 2001 From: Evan Boehs Date: Tue, 16 Jul 2024 09:46:59 -0400 Subject: [PATCH] mode constant --- constants.ts | 1 + server/auth.ts | 3 ++- server/captcha.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 constants.ts diff --git a/constants.ts b/constants.ts new file mode 100644 index 0000000..f08c4f0 --- /dev/null +++ b/constants.ts @@ -0,0 +1 @@ +export const MODE = import.meta.env.MODE; diff --git a/server/auth.ts b/server/auth.ts index 8fa2bb9..5e60787 100644 --- a/server/auth.ts +++ b/server/auth.ts @@ -7,6 +7,7 @@ import { getRequestEvent } from "solid-js/web"; import bcrypt from "bcryptjs"; import { Database } from "../../schema"; import { cfMiddleware } from "./logger"; +import { MODE } from "oss/constants"; const jwtType = t.Object({ id: t.Number(), @@ -171,7 +172,7 @@ export const requireAuth = (allowRead: T) => cookie.token.maxAge = 60 * 60 * 24 * 30; cookie.token.sameSite = "strict"; cookie.token.httpOnly = true; - cookie.token.secure = !(import.meta.env.MODE == "development"); + cookie.token.secure = !(MODE == "development"); cookie.token.path = "/"; return newJwtVerified || undefined; } diff --git a/server/captcha.ts b/server/captcha.ts index 12c93a6..e4502a6 100644 --- a/server/captcha.ts +++ b/server/captcha.ts @@ -2,6 +2,7 @@ import { HttpError } from "#/plugins/error"; import { StatusMap } from "elysia"; +import { MODE } from "oss/constants"; const errorStringMap = { "missing-input-secret": "The secret parameter was not passed.", @@ -31,7 +32,7 @@ const NOT_SO_SECRET_TESTING_KEYS = { export async function captcha(context: { ip?: string; response: string }) { const secret = - import.meta.env.MODE == "development" + MODE == "development" ? NOT_SO_SECRET_TESTING_KEYS.always_pass : process.env.CAPTCHA_PRIVATEKEY!; const formData = new FormData();