# Portal off switch (Main · white-label client sites)

**Portal:** Main · **Switch:** `FEATURE_PORTAL_ENABLED` → `config('features.portal_enabled')` (default **on**) ·
**Rule:** `App\Http\Middleware\EnsurePortalEnabled`, in the `web` group · **Nav:** hides the manage sidebar's
"Switch to User Portal" and the Hub's "Investor Portal" link (`features.portal` shared prop) · **Writes:** none.

## What it does

Turns the member portal and the public property site OFF on a deployment that runs only the back office. Built
2026-11-04 for powerhome.propertylabglobal.com (Caroll), a white-label client whose scope was "our webinar
functions + VF functions, no need portal functions": funnels, Facebook lead gen, webinars, AI WhatsApp and the AI
caller, but no members of its own and no PropertyLab property site.

With the switch off, a portal page answers:

| Who opens it | Result |
|---|---|
| Staff (`User::isManageUser()`) | Redirect to their back-office home (`ResolvesPortalHome::homeFor(…, PORTAL_ADMIN)`) |
| A guest | Redirect to `/manage/login`, so typing the bare domain opens the sign-in |
| A signed-in customer | 404, since there is nothing on such a site for them |

Everything a funnel's lead opens keeps working: the `/{slug}` and `/{funnel}/{slot}` landings, `POST register`,
thank-you, `pay/*`, `book/*` and `booking/*`, `zoom/{token}`, `t/{id}` tickets, `wa/{slug}`, `ai-callback`,
consent and financial-report links, property-match, offer boards, `og-image` and `file` links, `privacy`, the
email unsubscribe links, the magic sign-in and OTP endpoints, webhooks and every `/manage` page.

## How it works

- **Matched by route name, like `RedirectToCanonicalHost`.** A page is closed when its name starts with one of
  `PORTAL_PREFIXES` (`main.site.`, `localized.main.site.`, `main.portal.`, `main.profile.`, `main.dashboard`,
  `public.rental-estimate`) or is one of `PORTAL_PAGES` (`landing` = `/`, `login`, `register.show`,
  `main.sitemap`), and is not in `KEEP_OPEN` (`main.site.privacy`, the two AI E-Learning unsubscribe links).
  Checked on 2026-11-04 against `route:list`: all 175 signed-in non-manage web routes fall under those names, and
  every route left open is one of the lead-facing pages above.
- **The routes stay registered.** The other `features.*` switches skip route registration, but dozens of
  redirects name `main.dashboard` (`EnsureUserIsAdmin`, `MagicLoginController`, `homeFor`); unregistering it would
  turn them into exceptions. The middleware answers instead.
- **A new portal page is covered only if its route name follows the convention.** Name it under one of the
  prefixes. A page a lead must reach goes OUTSIDE them, or into `KEEP_OPEN` if it has to live under one.
- **Not covered:** `member-api/*` and `mobile-api/*`. The member app is built against PropertyLab's own host, so a
  client deployment never receives those calls.
- **WhatsApp welcome `{{login_link}}`** still mints a magic link to `/dashboard`, which this switch turns into a
  404 for the lead. A client site's funnel templates should not use that variable.
- **The Hub is a separate switch** (a database setting, no deploy): Setting → Landing Page → "Turn the Hub off"
  sends the Hub's address to the chosen suite and hides "Back to Hub". A one-suite client such as VF usually wants
  both. See `docs/modules_handbook/manage/settings/landing-page/readMe.md`.

## Turning it on for a deployment

```
FEATURE_PORTAL_ENABLED=false
```

Then `php artisan config:cache` (the deploy does this). `0`, `off` and `no` also switch it off; an unrecognised
value leaves the portal ON.

## Related files

- `app/Http/Middleware/EnsurePortalEnabled.php`: the rule and the three name lists
- `app/Http/Kernel.php`: registered in the `web` group after `RedirectToCanonicalHost`
- `config/features.php`: `portal_enabled`
- `app/Http/Middleware/HandleInertiaRequests.php`: `features.portal`
- `resources/js/Layouts/ManageLayout.vue`, `resources/js/Pages/Manage/Dashboard.vue`: the two links into the portal
- `tests/Feature/Auth/PortalDisabledTest.php`
