> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign-in and sign-out

> How the customer enters and leaves the portal with their B Brands account, what happens to the session and what to do when it does not open.

## At a glance

| Field | Value |
| - | - |
| Status | **Available** |
| Route | Every private route; sign-in happens in `horizon-authenticate` (`/auth/login`) |
| Menu | User menu (initials, top right) › **Cerrar sesión** (Sign out) |
| Feature flag | None: sign-in is mandatory in every environment |
| Who sees it | Every customer who opens a private section |
| Last verified | 2026-11-10 against `develop` (`c10d24f33d`) |

## What it is for

The portal has no sign-in screen of its own. When the customer opens any private section without being signed
in, the portal sends them to the B Brands sign-in page (`horizon-authenticate`), the same one the MaihueGO app and
the other websites use. Once done, they come back to exactly the address they wanted. To leave, they use **Sign
out** in the user menu.

## How to get there

* Opening any private portal address (for example `https://portal.maihuego.com/es/home`) without a session.
* From a link in a Maihue e-mail that points to a private section.
* To leave: user menu › **Sign out**.

![The customer opens a private route; without a session they go to the horizon-authenticate sign-in, which sends them back to the portal with a bbx code; the portal swaps it for the session cookie and shows the section. Sign out goes through /logout and horizon-authenticate.](https://mintcdn.com/bbrands/w6DX1nTsRjzB7VQp/images/portal-customer-manual/sign-in-navigation.svg?fit=max\&auto=format\&n=w6DX1nTsRjzB7VQp\&q=85\&s=27e0a1d76a5e401a24a602cf91d2b121)

How the customer enters and leaves the portal

## What the customer sees

> [tab] Desktop
>
> ![User menu open with the customer's name and e-mail, My account, Help center and Send feedback marked Coming soon, and Sign out.](https://mintcdn.com/bbrands/Gtthq4FwpUS-9kET/images/portal-customer-screens/sign-in/user-menu.en.desktop.webp?fit=max\&auto=format\&n=Gtthq4FwpUS-9kET\&q=85\&s=f303efa5489735afa4f3680685e17e73)
>
> User menu open

> [tab] Mobile
>
> ![User menu open on mobile.](https://mintcdn.com/bbrands/RmQmo8S4AibSINhm/images/portal-customer-screens/sign-in/user-menu.en.mobile.webp?fit=max\&auto=format\&n=RmQmo8S4AibSINhm\&q=85\&s=62fd5f7aa9e6740f15bcce33850db412)
>
> User menu on mobile

| Element | What it does |
| - | - |
| Name and e-mail | Show which B Brands account the customer is signed in with |
| **My account** | Opens the Account section |
| **Help center** and **Send feedback** | Disabled, marked **Coming soon** |
| **Sign out** | Signs out in this browser and in B Brands |

## Step by step

### Sign in

**1. Open the portal**

The customer opens `https://portal.maihuego.com` or any portal link. Without a session, the portal redirects
them straight to the B Brands sign-in page.

**2. Sign in to B Brands**

They type their e-mail and follow the path the page offers: password, Google, Apple, Microsoft or an e-mail
link, depending on how they created the account. The screens are described in
[Sign in](https://docs.bbrands.io/maihuego/authentication/sign-in.md).

**3. Back to the portal**

Once done, B Brands sends them back to the address they had opened. For a moment they see a loading
indicator while the portal confirms the session, then the section.

### Sign out

**1. Open the user menu**

Tap the initials at the top right.

**2. Choose Sign out**

The portal records the device sign-out, closes the session on the server and takes them to B Brands, which
also closes the shared session. To come back they sign in again.

### When the session does not open

**1. The customer sees “We could not open your session”**

> [tab] Desktop
>
> ![We could not open your session screen with the Sign in again button.](https://mintcdn.com/bbrands/Gtthq4FwpUS-9kET/images/portal-customer-screens/sign-in/session-unavailable.en.desktop.webp?fit=max\&auto=format\&n=Gtthq4FwpUS-9kET\&q=85\&s=0ccbe03faf68bb9e63f425b89fab9c31)

> [tab] Mobile
>
> ![We could not open your session screen on mobile.](https://mintcdn.com/bbrands/Gtthq4FwpUS-9kET/images/portal-customer-screens/sign-in/session-unavailable.en.mobile.webp?fit=max\&auto=format\&n=Gtthq4FwpUS-9kET\&q=85\&s=fc5d45708b7eb85564209d5ba94de0d4)

**2. Sign in again**

Tap **Sign in again**. If it shows up again, see the support cases below.

## Business rules

| ID | Rule |
| - | - |
| R-01 | Every private route needs a session, in every environment (local included). It cannot be switched off |
| R-02 | Without a session cookie, the portal redirects to `horizon-authenticate` with `next=<current address>` to come back to the same place |
| R-03 | A session lasts at most 30 days (`AUTH_SESSION_MAX_AGE`); once expired, the customer signs in again |
| R-04 | The `bbx` code that hands over the session works once and only in the browser that asked for it (ADR 0138) |
| R-05 | If the customer comes back from sign-in and the portal still has no session, it does not redirect again: it shows "We could not open your session" to avoid a loop |
| R-06 | Sign out always goes through the portal's `/logout` (clears its cookie) and then `horizon-authenticate` (clears the shared session) |

## States and messages

| State | What the customer sees | Why | What to do |
| - | - | - | - |
| Checking | Full-screen loading indicator | The portal checks the session before showing data | Wait a moment |
| Signed in | The section | There is a valid session | — |
| Signed out | The B Brands sign-in page | No session cookie, or it expired | Sign in |
| Session unavailable | "We could not open your session" with **Sign in again** | Came back from sign-in and the portal got no valid session | See support cases |

## Errors

| Message | Cause | Backend code | Support action |
| - | - | - | - |
| "We could not open your session. Your sign-in completed but the portal did not receive a valid session. Please sign in again; if the problem persists, contact support." | The `bbx` exchange failed, the browser blocked the cookie or the session expired right on return | — (client state, `GET /api/auth/session` answered `{ token: null }`) | Ask them to retry; if it persists, to try without blocking extensions or in another browser, and escalate to Frontend Platform with time and browser |
| "Something went wrong. Please try again." | Unhandled error while loading | — | Retry; if it persists, escalate with the portal version (sidebar footer) |

## Why it works this way

![Sequence: without a cookie the portal redirects to horizon-authenticate; after sign-in it comes back with bbx; the portal proxy swaps the bbx for the bbrands\_session cookie; the app guard asks /api/auth/session and shows the section or the session unavailable state.](https://mintcdn.com/bbrands/w6DX1nTsRjzB7VQp/images/portal-customer-manual/sign-in-process.svg?fit=max\&auto=format\&n=w6DX1nTsRjzB7VQp\&q=85\&s=902d2ed401f5fc650f34a430d34654f2)

Portal sign-in process

* **One sign-in for all of B Brands.** The customer uses the same account in the portal, the app and the other
  websites. That is why the portal has no form of its own: it delegates to `horizon-authenticate`.
* **A cookie of the portal's own.** The portal lives on `*.maihuego.com` and `horizon-authenticate` on
  `*.bbrands.io`. They are different domains and the browser does not share cookies between them, so the portal
  keeps its own session cookie (created from the `bbx`) and reads it on its own domain.
* **No loops.** If the session does not arrive after coming back from sign-in, redirecting again would only spin
  the customer forever; so it stops and shows the notice.

## Technical detail

| Aspect | Detail |
| - | - |
| Signed-out redirect and `bbx` exchange | `frontend/portal-customer/proxy.ts` (`createSsoProxy` from `@bbrandslab/auth-sso/proxy`) |
| Pages open without a session | Sign-in landing, digital contract, onboarding activation, the scheduling link of maintenance emails (`/{locale}/m/{token}`, see [Schedule maintenance](https://docs.bbrands.io/portal-customer/scheduling.md)), payment returns and `/redirect` |
| Cookie | `bbrands_session` in production and `bbrands_session_<tier>` elsewhere (ADR 0014), HttpOnly, `SameSite=Lax` |
| Session check in the browser | `GET /api/auth/session` (`app/api/auth/session/route.ts`) → `{ token }` or `{ token: null }` |
| App guard | `app/lib/providers/portal-sso-guard.tsx` (`portal:sso:bounced` marker in `sessionStorage`) |
| Sign out | `app/lib/auth/logout.ts`: `POST /api/v3/auth/logout`, then `/logout` → `{authenticate}/api/auth/logout` |
| User menu | `app/lib/shell/user-menu.tsx` |
| Texts | `messages/{es,en}.json` › `common.sessionUnavailable*`, `userMenu` |
| Initiatives | `authenticate/session` (SSO and `bbx`), `portal-customer/portal-shell` |

## FAQ and support cases

> [accordion] The customer says the portal keeps asking them to sign in
>
> If they see the sign-in every time they open the portal, their session expired (30 days) or their browser
> clears cookies on close. If after signing in they see "We could not open your session", the browser is
> blocking the portal cookie: ask them to try without blockers or in another browser.

> [accordion] Which account does the customer use for the portal?
>
> Their B Brands account: the same as the MaihueGO app. If they do not remember how they created it, the
> sign-in page shows the paths available for their e-mail.

> [accordion] The customer signed out of the portal and is still signed in to the app
>
> That is expected: signing out of the portal closes the B Brands web session in that browser, not the mobile
> app's.

> [accordion] The customer wants to sign in with a password and has none
>
> They can sign in with the e-mail link or their provider and then create a password in
> **Account › Security**.

## Related and history

* [Act as](https://docs.bbrands.io/portal-customer/access/act-as-company.md)
* [Navigation map](https://docs.bbrands.io/portal-customer/navigation-map.md)
* [Sign in to B Brands](https://docs.bbrands.io/maihuego/authentication/sign-in.md) and [Session](https://docs.bbrands.io/maihuego/authentication/session.md)

| Date | Change |
| - | - |
| 2026-11-10 | First version |
| 2026-11-23 | `/{locale}/m/{token}` opens without a session (`notification/contactability-events` T-15) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.