diff --git a/server/middleware/tester.ts b/server/middleware/tester.ts index f4494a3..270fad0 100644 --- a/server/middleware/tester.ts +++ b/server/middleware/tester.ts @@ -5,8 +5,17 @@ import type { JwtPayload } from "../types/JwtPayload.js"; const JWT_SECRET = process.env.JWT_SECRET; +function shouldBypassTesterGate(req: Request): boolean { + const host = req.get('host') || req.get('x-forwarded-host') || ''; + return host === 'control.pfconnect.online'; +} + export async function requireTester(req: Request, res: Response, next: NextFunction) { try { + if (shouldBypassTesterGate(req)) { + return next(); + } + const settings = await getTesterSettings(); if (!settings.tester_gate_enabled) { return next(); @@ -48,6 +57,20 @@ export async function isTester(userId: string) { export async function checkTesterGateStatus() { try { + const settings = await getTesterSettings(); + return settings.tester_gate_enabled || false; + } catch (error) { + console.error('Error checking tester gate status:', error); + return true; + } +} + +export async function checkTesterGateStatusWithDomain(host?: string) { + try { + if (host === 'control.pfconnect.online') { + return false; + } + const settings = await getTesterSettings(); return settings.tester_gate_enabled || false; } catch (error) { diff --git a/src/App.tsx b/src/App.tsx index 91253d8..f4fb80a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -51,6 +51,10 @@ export default function App() { const [showUpdateModal, setShowUpdateModal] = useState(false); const [activeModal, setActiveModal] = useState(null); + const shouldBypassTesterGate = () => { + return window.location.hostname === 'control.pfconnect.online'; + }; + useEffect(() => { const checkGlobalHolidayStatus = async () => { try { @@ -96,6 +100,12 @@ export default function App() { useEffect(() => { const checkGateStatus = async () => { try { + // Bypass tester gate for control.pfconnect.online + if (shouldBypassTesterGate()) { + setTesterGateEnabled(false); + return; + } + const settings = await getTesterSettings(); if (settings && typeof settings.tester_gate_enabled === 'boolean') { @@ -150,6 +160,7 @@ export default function App() { {activeModal && (!testerGateEnabled || + shouldBypassTesterGate() || (testerGateEnabled && user?.isTester) || user?.isAdmin) && (