From e0a245a9d35ee85eb7e16b455bedb5c2f86ed0ce Mon Sep 17 00:00:00 2001
From: Sumit Kumar
Date: Mon, 1 Jun 2026 22:49:08 +0530
Subject: [PATCH 1/2] fix: change 404 page link from /dashboard to / for
unauthenticated users
---
client/src/pages/not-found.tsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/src/pages/not-found.tsx b/client/src/pages/not-found.tsx
index a41fda2ea..e37105709 100644
--- a/client/src/pages/not-found.tsx
+++ b/client/src/pages/not-found.tsx
@@ -14,10 +14,10 @@ export default function NotFound() {
The page you're looking for doesn't exist or has been moved.
- Back to Dashboard
+ Back to Home
From dd87ca84159e6557a93624935468b047e63fca7b Mon Sep 17 00:00:00 2001
From: Sumit Kumar
Date: Mon, 1 Jun 2026 23:02:49 +0530
Subject: [PATCH 2/2] fix: resolve syntax errors in auth.ts and rateLimiter.ts
for CI
---
server/auth.ts | 61 ++++++++++++++++++++------------
server/middleware/rateLimiter.ts | 2 +-
2 files changed, 40 insertions(+), 23 deletions(-)
diff --git a/server/auth.ts b/server/auth.ts
index cde5a1d0a..92234d029 100644
--- a/server/auth.ts
+++ b/server/auth.ts
@@ -26,6 +26,27 @@ interface RegisteredUser {
// removed duplicated functions
+const SALT_LENGTH = 32;
+const KEY_LENGTH = 64;
+
+function hashPassword(password: string): string {
+ const salt = randomBytes(SALT_LENGTH).toString("hex");
+ const hash = scryptSync(password, salt, KEY_LENGTH).toString("hex");
+ return `${salt}:${hash}`;
+}
+
+function verifyPassword(password: string, stored: string): boolean {
+ const [salt, key] = stored.split(":");
+ if (!salt || !key) return false;
+ const hash = scryptSync(password, salt, KEY_LENGTH);
+ const keyBuffer = Buffer.from(key, "hex");
+ return hash.length === keyBuffer.length && timingSafeEqual(hash, keyBuffer);
+}
+
+function ipKeyGenerator(ip: string): string {
+ return ip.replace(/[^a-zA-Z0-9.:]/g, "_");
+}
+
/**
* In-memory store for registered users.
* In production, this should be replaced with a persistent database.
@@ -204,12 +225,6 @@ export function createAuthRouter(): Router {
if (existingDbUser) {
return res.status(409).json({ message: "An account with this email already exists." });
}
- registeredUsers.set(email, {
- fullName,
- email,
- passwordHash: hashPassword(password),
- licenseNumber: licenseNumber,
- });
const passwordHash = hashPassword(password);
@@ -246,10 +261,14 @@ export function createAuthRouter(): Router {
attemptCount: 0,
});
- // In production, send OTP via email. For development, return it in the response.
- logDevOtp(email, otp);
+ // In production, send OTP via email. For development, return it in the response.
+ logDevOtp(email, otp);
- return res.status(201).json({ success: true, pendingEmail: email, ...(process.env.NODE_ENV !== "production" && { devOtp: otp }) });
+ return res.status(201).json({ success: true, pendingEmail: email, ...(process.env.NODE_ENV !== "production" && { devOtp: otp }) });
+ } catch (err) {
+ console.error("Registration error:", err);
+ return res.status(500).json({ message: "Registration failed due to a server error." });
+ }
});
/**
@@ -276,11 +295,11 @@ export function createAuthRouter(): Router {
// Check in-memory store (legacy)
const registeredUser = registeredUsers.get(email);
if (registeredUser && verifyPassword(password, registeredUser.passwordHash)) {
- userFullName = registeredUser.fullName;
+ userName = registeredUser.fullName;
}
// Also check DB
- if (!userFullName) {
+ if (!userName) {
try {
const db = getDb();
const [dbUser] = await db
@@ -290,21 +309,21 @@ export function createAuthRouter(): Router {
.limit(1);
if (dbUser && verifyPassword(password, dbUser.passwordHash)) {
- userFullName = dbUser.fullName;
+ userName = dbUser.fullName;
+ }
+ } catch (_err) {
+ // DB not available — fall back to in-memory only
+ console.warn("DB unavailable for login, using in-memory only.");
+ const registeredUser = registeredUsers.get(email);
+ if (registeredUser && verifyPassword(password, registeredUser.passwordHash)) {
+ userName = registeredUser.fullName;
}
- }
- } catch (_err) {
- // DB not available — fall back to in-memory only
- console.warn("DB unavailable for login, using in-memory only.");
- const registeredUser = registeredUsers.get(email);
- if (registeredUser && verifyPassword(password, registeredUser.passwordHash)) {
- userFullName = registeredUser.fullName;
}
}
}
- if (!userFullName) {
+ if (!userName) {
return res.status(401).json({ message: "Invalid email or password." });
}
@@ -346,9 +365,7 @@ export function createAuthRouter(): Router {
pendingOtps.delete(email);
- const registeredUser = registeredUsers.get(email);
const devEmail = process.env.DEV_CLINICIAN_EMAIL || "";
- const name = email === devEmail ? "Dr. Smith" : (registeredUser?.fullName ?? email);
let id: string;
let name: string;
diff --git a/server/middleware/rateLimiter.ts b/server/middleware/rateLimiter.ts
index d19fa96a4..f7d66b5e8 100644
--- a/server/middleware/rateLimiter.ts
+++ b/server/middleware/rateLimiter.ts
@@ -11,7 +11,7 @@ function pruneExpiredRecords(now: number) {
if (now > record.resetTime) {
requestStore.delete(clientId);
}
- });
+ }
}
function trimRequestStore(now: number) {