Skip to content

Commit

Permalink
mode constant
Browse files Browse the repository at this point in the history
  • Loading branch information
boehs committed Jul 16, 2024
1 parent d843b9f commit bedba32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const MODE = import.meta.env.MODE;
3 changes: 2 additions & 1 deletion server/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -171,7 +172,7 @@ export const requireAuth = <T extends boolean>(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;
}
Expand Down
3 changes: 2 additions & 1 deletion server/captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit bedba32

Please sign in to comment.