fix: name the step-up gate on the two acts that carry one

- deleting a profile and ending a guardian's access resolve fresh MFA,
  and both sit behind a confirmation, so the request that reaches the
  server is minutes old and routinely outside the five-minute window
- an account with no second factor is told where to set one up instead
  of being asked to confirm one it does not have
- the arm is scoped to those two acts: a 401 on accept, revoke or
  renounce is a lapsed session and must not read as a factor prompt
This commit is contained in:
Marc-André Bombeck committed 2026-08-07 03:55:25 +02:00
1 parent 217b0f41d8
commit 29940afb57
9 files changed
+108 -8

No files matched your search

+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "Ein verwaltetes Profil kann keine andere Akte betreuen. Lade ein Konto ein, das sich anmeldet.",
"guardianErrorNoAccount": "Auf dieser Instanz gibt es kein Konto mit diesem Namen oder dieser E-Mail-Adresse.",
"guardianErrorRateLimit": "Zu viele Einladungen in der letzten Stunde. Warte etwas und versuche es erneut.",
"guardianErrorFailed": "Die Einladung konnte nicht gesendet werden."
"guardianErrorFailed": "Die Einladung konnte nicht gesendet werden.",
"errorMfaRequired": "Dafür ist ein zweiter Faktor nötig, und dein Konto hat noch keinen. Richte unter Einstellungen → Sicherheit einen ein und versuche es dann erneut.",
"rosterLoadError": "Es ließ sich nicht laden, wer sich um diese Akte kümmert.",
"errorRateLimit": "Zu viele Profile in der letzten Stunde angelegt. Warte etwas und versuche es erneut."
},
"toast": {
"savedTo": "In der Akte von {name} gespeichert."
+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "A managed profile cannot look after another record. Invite an account that signs in.",
"guardianErrorNoAccount": "No account on this instance carries that name or e-mail.",
"guardianErrorRateLimit": "Too many invitations in the last hour. Wait a while and try again.",
"guardianErrorFailed": "The invitation could not be sent."
"guardianErrorFailed": "The invitation could not be sent.",
"errorMfaRequired": "This needs a second factor, and your account does not have one yet. Set one up under Settings → Security, then try again.",
"rosterLoadError": "Could not load who looks after this record.",
"errorRateLimit": "Too many profiles created in the last hour. Wait a while and try again."
},
"toast": {
"savedTo": "Saved to {name}'s record."
+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "Un perfil administrado no puede ocuparse de otro historial. Invita a una cuenta que inicie sesión.",
"guardianErrorNoAccount": "En esta instancia no hay ninguna cuenta con ese nombre o correo.",
"guardianErrorRateLimit": "Demasiadas invitaciones en la última hora. Espera un poco y vuelve a intentarlo.",
"guardianErrorFailed": "No se pudo enviar la invitación."
"guardianErrorFailed": "No se pudo enviar la invitación.",
"errorMfaRequired": "Esto necesita un segundo factor y tu cuenta aún no tiene ninguno. Configura uno en Ajustes → Seguridad y vuelve a intentarlo.",
"rosterLoadError": "No se pudo cargar quién se ocupa de este historial.",
"errorRateLimit": "Demasiados perfiles creados en la última hora. Espera un poco y vuelve a intentarlo."
},
"toast": {
"savedTo": "Guardado en el historial de {name}."
+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "Un profil géré ne peut pas s'occuper d'un autre dossier. Invitez un compte qui se connecte.",
"guardianErrorNoAccount": "Aucun compte de cette instance ne porte ce nom ou cette adresse e-mail.",
"guardianErrorRateLimit": "Trop d'invitations dans la dernière heure. Patientez un peu et réessayez.",
"guardianErrorFailed": "L'invitation n'a pas pu être envoyée."
"guardianErrorFailed": "L'invitation n'a pas pu être envoyée.",
"errorMfaRequired": "Cela demande un deuxième facteur, et votre compte n'en a pas encore. Configurez-en un dans Réglages → Sécurité, puis réessayez.",
"rosterLoadError": "Impossible de charger qui s'occupe de ce dossier.",
"errorRateLimit": "Trop de profils créés dans la dernière heure. Patientez un peu et réessayez."
},
"toast": {
"savedTo": "Enregistré dans le dossier de {name}."
+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "Un profilo gestito non può occuparsi di un'altra cartella. Invita un account che accede da sé.",
"guardianErrorNoAccount": "Su questa istanza non esiste un account con quel nome o quella e-mail.",
"guardianErrorRateLimit": "Troppi inviti nell'ultima ora. Aspetta un po' e riprova.",
"guardianErrorFailed": "Non è stato possibile inviare l'invito."
"guardianErrorFailed": "Non è stato possibile inviare l'invito.",
"errorMfaRequired": "Serve un secondo fattore e il tuo account non ne ha ancora uno. Impostane uno in Impostazioni → Sicurezza e riprova.",
"rosterLoadError": "Non è stato possibile caricare chi si occupa di questa cartella.",
"errorRateLimit": "Troppi profili creati nell'ultima ora. Aspetta un po' e riprova."
},
"toast": {
"savedTo": "Salvato nella cartella di {name}."
+4 -1
View File
@@ -9692,7 +9692,10 @@
"guardianErrorManagedInvitee": "Zarządzany profil nie może opiekować się inną kartą. Zaproś konto, które samo się loguje.",
"guardianErrorNoAccount": "W tej instancji nie ma konta o takiej nazwie ani takim adresie e-mail.",
"guardianErrorRateLimit": "Zbyt wiele zaproszeń w ostatniej godzinie. Odczekaj chwilę i spróbuj ponownie.",
"guardianErrorFailed": "Nie udało się wysłać zaproszenia."
"guardianErrorFailed": "Nie udało się wysłać zaproszenia.",
"errorMfaRequired": "To wymaga drugiego składnika logowania, a Twoje konto jeszcze go nie ma. Skonfiguruj go w Ustawieniach → Bezpieczeństwo i spróbuj ponownie.",
"rosterLoadError": "Nie udało się wczytać, kto opiekuje się tą kartą.",
"errorRateLimit": "Zbyt wiele profili utworzonych w ostatniej godzinie. Odczekaj chwilę i spróbuj ponownie."
},
"toast": {
"savedTo": "Zapisano w karcie użytkownika {name}."
@@ -231,6 +231,36 @@ describe("what a refused sharing action says", () => {
key: "recordSharing.actionError.deleteProfileFailed",
why: "anything the delete route does not classify becomes the generic envelope and must not borrow a diagnosis",
},
{
action: "deleteProfile",
err: apiError(401, "auth.stepup.required"),
key: "recordSharing.managed.errorStepUp",
why: "the step-up window lapsed while the confirm dialog was open — the likeliest refusal of the two acts that carry a gate",
},
{
action: "removeGuardian",
err: apiError(401, "auth.stepup.required"),
key: "recordSharing.managed.errorStepUp",
why: "the same gate on the other confirmed act",
},
{
action: "deleteProfile",
err: apiError(401, "auth.stepup.mfa_not_enrolled"),
key: "recordSharing.managed.errorMfaRequired",
why: "no second factor at all: 'confirm your second factor' is a dead end, and enrolling is the only way through",
},
{
action: "accept",
err: apiError(401),
key: "recordSharing.actionError.acceptFailed",
why: "a 401 on a route with NO step-up gate is a lapsed session, and must not tell somebody to confirm a factor",
},
{
action: "renounce",
err: apiError(401),
key: "recordSharing.actionError.renounceFailed",
why: "same, from the delegate's side",
},
{
action: "removeGuardian",
err: new TypeError("Failed to fetch"),
@@ -47,6 +47,38 @@ const FAILED_KEY: Record<GrantAction, string> = {
removeGuardian: "recordSharing.actionError.removeGuardianFailed",
};
/**
* The acts whose routes resolve `requireFreshMfa`, and therefore the only ones
* where a 401 is a gate rather than a lapsed session.
*
* A set rather than a condition, so adding a third step-up-gated act is one
* line here instead of a boolean somebody has to re-derive.
*/
const STEP_UP_ACTIONS = new Set<GrantAction>([
"deleteProfile",
"removeGuardian",
]);
/**
* Which of the two step-up sentences a 401 from the managed-profile family
* earns.
*
* `requireFreshMfa` refuses for two different reasons and says which: a stale
* proof (`auth.stepup.required`), which the person clears by proving their
* factor, and NO factor at all (`auth.stepup.mfa_not_enrolled`), which they
* cannot clear that way. Collapsing the two tells somebody with no second
* factor to confirm one — a dead end offered by the very surface that owns
* the route out of it.
*
* Exported and shared by every caller in the family (creation, the guardian
* invitation, and the two acts below) so the two sentences cannot come apart.
*/
export function stepUpErrorKey(err: ApiError): string {
return err.meta?.errorCode === "auth.stepup.mfa_not_enrolled"
? "recordSharing.managed.errorMfaRequired"
: "recordSharing.managed.errorStepUp";
}
/**
* The message key for a refused grant action.
*
@@ -102,6 +134,24 @@ export function grantActionErrorKey(err: unknown, action: GrantAction): string {
// route rate-limits without an error code, hence the status.
if (err.status === 429) return "recordSharing.actionError.rateLimited";
// v1.37.0 — the step-up gate, on the two acts that carry one.
//
// Scoped by action rather than applied to every 401, and that is the whole
// care in it. `DELETE /api/managed-profiles/{id}` and
// `DELETE .../guardians/{grantId}` resolve `requireFreshMfa`, so a 401 there
// is a gate somebody can clear. Accept, revoke and renounce resolve plain
// `requireAuth`, where a 401 means the session ended — and telling that
// person to confirm a second factor sends them looking for the wrong thing.
//
// These two are also the likeliest to hit it: both sit behind a
// `ConfirmButton`, so the click that reaches the server is the second one,
// minutes after the panel was opened, and the five-minute window is easy to
// be outside of by then. Before this arm they fell through to "the profile
// could not be deleted", which describes nothing and offers nothing.
if (err.status === 401 && STEP_UP_ACTIONS.has(action)) {
return stepUpErrorKey(err);
}
return FAILED_KEY[action];
}
@@ -5,6 +5,7 @@ import { useState } from "react";
import {
GrantActionAlert,
grantActionErrorKey,
stepUpErrorKey,
} from "@/components/settings/access/grant-action-error";
import { endOfDayIso } from "@/components/settings/access/grant-invite-card";
import { Button } from "@/components/ui/button";
@@ -334,7 +335,8 @@ export function guardianInviteErrorKey(err: unknown): string {
// identifier is the recovery for the other, so they must not collapse.
if (err.status === 429) return "recordSharing.managed.guardianErrorRateLimit";
if (err.status === 404) return "recordSharing.managed.guardianErrorNoAccount";
// The step-up gate this whole family carries. Not a failure.
if (err.status === 401) return "recordSharing.managed.errorStepUp";
// The step-up gate this whole family carries. Not a failure — and it comes
// in two shapes, because an account with no factor enrolled cannot clear it.
if (err.status === 401) return stepUpErrorKey(err);
return "recordSharing.managed.guardianErrorFailed";
}