> ## 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.

# Password

> The password is optional: the 4-of-5 rule, creating and changing a password in MaihueGO and the portal, the security e-mails and recovery.

From 2026.11.3 the password is **optional** for every login (ADR 0132). Whoever registers with Google,
Apple or Microsoft goes through no password step: they sign in straight away and can create one later.
The `has_created_password` field of `user_metadata` says whether the login has one, and every surface
reads it from `verify-email` and `profile/me`.

> [!NOTE]
>
> **Status.** Create and change ship in PR #1960 (merged into develop on 2026-11-05) with 2026.11.3, with no
> flag. The exit check is MT-07 and MT-08 on iOS and Android, plus the portal Playwright suites.

## The rule: 4 of 5 plus confirmation

One rule for the API, MaihueGO, horizon-authenticate and the portal
(`lib/endpoint/auth/shared/password-rules.ts`, `MIN_PASSWORD_REQUIREMENTS = 4`). The password must meet
at least four of these five criteria:

| # | Criterion |
| - | - |
| 1 | At least 8 characters |
| 2 | A lowercase letter |
| 3 | An uppercase letter |
| 4 | A number |
| 5 | A special character (for example `!`, `@`, `#`, `%`, `*` or `?`) |

Every screen also asks to **confirm** the password (the confirmation is checked client side). Other
bounds: GoTrue rejects fewer than 6 characters and MaihueGO accepts up to 72.

> [!WARNING]
>
> **Open contradiction.** Imported decision D-331 required all five criteria on MaihueGO (the e-mail
> registration screen enables the button only at «excellent» strength). ADR 0132 and the initiative's
> decision D-03 replace it with 4 of 5 everywhere. The MaihueGO alignment (T-05) was merged in
> \#1960: until 2026.11.3 is published, the app's e-mail registration still asks for all five.

## Where it is created or changed

> [tab] MaihueGO
>
> * **Fixed yellow alert** at the top of Home, **with no close button**, while the login has no
>   password: «Crea tu contraseña», «Así también podrás ingresar con tu correo y contraseña.» and the
>   «Crear» button.
> * «Crear» opens a bottom sheet with «Contraseña», «Confirma tu contraseña» and the 4-of-5
>   indicator. It does not show the e-mail. The «Crear contraseña» button turns into «Creando
>   contraseña» and ends with «Contraseña creada».
> * **Settings** shows «Crear contraseña» or «Cambiar contraseña», as the case may be.
> * Change opens a sheet with the current password, the new one and the confirmation, plus the
>   «Cerrar sesión en los demás dispositivos» checkbox, **unchecked by default**. Success:
>   «Contraseña actualizada».
> * `hasCreatedPassword` lives in the session store (no longer hardcoded to `true`) and is refreshed
>   from `profile/me`.

> [tab] Customer portal
>
> * **Yellow banner** (HeroUI `Alert`, warning variant) with «Crear», which opens a modal, and «Ahora
>   no», which hides it in `sessionStorage` until the next sign-in.
> * New **Mi cuenta › Seguridad** section to create or change the password.

## Step by step: create

**1. The person opens the form**

From the Home alert or Settings (app), or from the banner or Mi cuenta › Seguridad (portal).

**2. Types and confirms**

The indicator marks the criteria met; the button is enabled with 4 of 5 and a matching
confirmation.

**3. The API stores it**

`POST /api/v3/auth/password` reuses `setUserPassword` and answers
`{ has_created_password: true }`. The `auth.password.created` e-mail is sent.

**4. The app and the portal update**

The alert or banner disappears and Settings switches to «Cambiar contraseña». From then on the
person can also sign in with e-mail and password.

If the login already had a password, the API answers `409`; the client refreshes `profile/me` and
offers to change it.

## Endpoints

| Method and path | Contract | Errors |
| - | - | - |
| `POST /api/v3/auth/password` | Horizon JWT. Body `{ password }` (up to 256 characters). Answers `{ has_created_password: true }`. | `409 password-already-created`, `422 password-too-weak` |
| `POST /api/v3/auth/password/change` | Horizon JWT. Body `{ current_password, new_password, revoke_other_sessions? }` (default `false`). The current password is checked with an isolated Supabase client. With `revoke_other_sessions: true` it rejects every earlier Horizon JWT of the login, ends its other GoTrue sessions (only this device's survives) and returns a new `jwt`; otherwise `jwt: null`. | `401 invalid-current-password`, `409 password-not-created`, `422 password-too-weak`, `503 password-changed-revocation-failed` |
| `POST /api/v3/auth/recovery-account` | Always the same answer, whether or not the e-mail exists. | — |
| `POST /api/v3/auth/reset-password` | Recovery token plus the new password. | See recovery |

Once Supabase holds the new password, the change stands and the `auth.password.changed` e-mail is always
sent. If a revocation step fails after that, the API answers `503 password-changed-revocation-failed`
with `password_changed: true` and `sessions_revoked` (`false` when a revocation failed): the person signs
in again with the new password, and changes it again to retry the revocation. MaihueGO and the portal
still show this answer as a generic error.

With revocation on, the device that made the change stays signed in with the new JWT. While the
answer is on its way, MaihueGO ignores a «token revoked» 401 on the old token, so a background
request cannot sign the device out (password D-07).

## Security e-mails

| Event | When |
| - | - |
| `auth.password.created` | A login without a password creates one |
| `auth.password.changed` | A login changes its password, with or without signing out other sessions |
| `auth.password.recovery-requested` | «Olvidé mi contraseña» on a login with a password |

They are in the security category: they cannot be opted out of and ignore quiet hours.

## Recovery

**1. Forgot password**

In the app or at `auth.bbrands.io/<locale>/auth/recovery-account`, the person types their e-mail
and `POST /api/v3/auth/recovery-account` is called.

**2. The API decides what to send**

* Login **with** a password: Supabase reset e-mail, pointing to
  `SUPABASE_AUTH_RECOVERY_PASSWORD_REDIRECT_TO`.
* Login **without** a password: the [sign-in magic link](https://docs.bbrands.io/maihuego/authentication/magic-link.md).
* Unknown or unconfirmed e-mail: nothing is sent.

In all three cases the answer is the same `{ success: true }` and the same message.

**3. Reset**

The `auth/reset-password` page sends the token and the new password to
`POST /api/v3/auth/reset-password`, with the 4-of-5 rule.

| `reset-password` response | When |
| - | - |
| `400` listing the missing criteria | The password does not meet 4 of 5 |
| `400 INVALID_TOKEN` | Expired, used or tampered link: ask for a new one |
| `RATE_LIMITED` | GoTrue answered `429` |
| Form error | GoTrue answered `422` after the link was consumed: ask for a new link and use a different password |

Recovery also resets the failed-attempt lockout counter.

## Limits

| Bucket | Limit | Dimensions | If the limiter is down | Over budget |
| - | - | - | - | - |
| `password` (create and change) | 10 per hour | user and IP | local | `429` (always enforced) |
| `recovery` | 3 per hour | e-mail and IP | closed | silent: same answer |
| `reset-password` | 10 per hour | IP | closed | `429` |

## See also

* [Magic link](https://docs.bbrands.io/maihuego/authentication/magic-link.md)
* [E-mail sign-in](https://docs.bbrands.io/maihuego/authentication/sign-in.md)
* [Registration](https://docs.bbrands.io/maihuego/authentication/registration.md)
* [Sessions and SSO](https://docs.bbrands.io/maihuego/authentication/session.md)
* [Security and limits](https://docs.bbrands.io/maihuego/authentication/security.md)


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