Improve admin password hash

This commit is contained in:
Dominic Ferrando
2026-07-18 01:54:23 -04:00
parent 38855af45d
commit 529e011dd2
2 changed files with 5 additions and 2 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ import {
Printful,
Webflow,
} from "@blade-and-brawn/commerce";
import { DEFAULT_NAME, env, log } from "./util";
import { DEFAULT_NAME, env, log, sha256Sum } from "./util";
import serverTiming from "@elysia/server-timing";
import jwt from "@elysia/jwt";
import { CommerceService, WOrderStatusSchema } from "./services/commerce";
@@ -122,7 +122,7 @@ export const app = new Elysia()
// AUTHENTICATION
.post("/auth/login", async ({ jwt, body, cookie: { auth } }) => {
const match = crypto.timingSafeEqual(Buffer.from(body.password, "hex"), Buffer.from(env.ADMIN_PASSWORD, "hex"));
const match = crypto.timingSafeEqual(sha256Sum(body.password), Buffer.from(env.ADMIN_PASSWORD, "hex"));
if (!match) throw status(401, "Invalid credentials");
auth.set({