diff --git a/surfsense_backend/app/app.py b/surfsense_backend/app/app.py index 1998f663f..8c7c53db7 100644 --- a/surfsense_backend/app/app.py +++ b/surfsense_backend/app/app.py @@ -17,11 +17,15 @@ async def lifespan(app: FastAPI): await create_db_and_tables() yield + def registration_allowed(): if not config.REGISTRATION_ENABLED: - raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="Registration is disabled") + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, detail="Registration is disabled" + ) return True + app = FastAPI(lifespan=lifespan) # Add CORS middleware @@ -67,7 +71,9 @@ if config.AUTH_TYPE == "GOOGLE": ), prefix="/auth/google", tags=["auth"], - dependencies=[Depends(registration_allowed)], # blocks OAuth registration when disabled + dependencies=[ + Depends(registration_allowed) + ], # blocks OAuth registration when disabled ) app.include_router(crud_router, prefix="/api/v1", tags=["crud"]) diff --git a/surfsense_web/app/(home)/register/page.tsx b/surfsense_web/app/(home)/register/page.tsx index 58641e2a1..c10f92b71 100644 --- a/surfsense_web/app/(home)/register/page.tsx +++ b/surfsense_web/app/(home)/register/page.tsx @@ -65,18 +65,18 @@ export default function RegisterPage() { const data = await response.json(); if (!response.ok && response.status === 403) { - const friendlyMessage = - "Registrations are currently closed. If you need access, contact your administrator."; - setErrorTitle("Registration is disabled"); - setError(friendlyMessage); - toast.error("Registration is disabled", { - id: loadingToast, - description: friendlyMessage, - duration: 6000, - }); - setIsLoading(false); - return; - } + const friendlyMessage = + "Registrations are currently closed. If you need access, contact your administrator."; + setErrorTitle("Registration is disabled"); + setError(friendlyMessage); + toast.error("Registration is disabled", { + id: loadingToast, + description: friendlyMessage, + duration: 6000, + }); + setIsLoading(false); + return; + } if (!response.ok) { throw new Error(data.detail || `HTTP ${response.status}`);