← All posts
BLOG · · Sebastien Le Touze

How LoginSeal handles passkey enrollment

A walk-through with code, gotchas, and one strong opinion.

1 MIN READ 6 SECTIONS TUTORIAL

Background

The problem started when we noticed an inconsistency between two surfaces that should have rendered identically. The fix turned out to involve three subsystems and a small philosophical question about who owns the canonical view.

Before we go further, a quick reminder: every change in this codebase ships through the same review pipeline. No exceptions.

What we tried first

Our first instinct was the obvious one: add a flag, paper over the difference, move on. That works for a sprint or two. It does not work for a year.

  • The flag would have to propagate into three layers.
  • The flag's default would surprise anyone reading the code cold.
  • The flag would never get removed.

So we went looking for the underlying invariant instead.

The fix

The real fix was structural. We extracted the rendering decision into a single function that both surfaces consume, and removed the duplicated logic. Net change: 28 lines removed, 19 added, one test file replaced.

Pseudocode:

function decide(Context $ctx): Decision
{
    if ($ctx->isStaff()) {
        return Decision::Show;
    }
    return $ctx->audience->canSee($ctx->post)
        ? Decision::Show
        : Decision::Hide;
}

Trade-offs

The same call across languages

Pick your stack:

$res = $client->post("https://loginseal.com/api/v1/anonymous-sessions", [
    "json" => ["client_id" => $id, "scope" => "anon:ephemeral"],
]);
res = requests.post("https://loginseal.com/api/v1/anonymous-sessions",
    json={"client_id": id, "scope": "anon:ephemeral"})
const res = await fetch(url, {
    method: "POST",
    body: JSON.stringify({ client_id, scope: "anon:ephemeral" }),
});
res, _ := http.Post(url, "application/json", body)

Centralising the decision means the function now has both reads. We accept that: the alternative, two slightly-different implementations, was strictly worse.

What is next

Two follow-up items: an audit of every other place we duplicated a decision, and a short post explaining the test we added so it does not regress.

← Previous
Per-user developer data and why it lives with us
Next →
Why our 2FA flow asks for the code twice
🇪🇺Operated in the European Union
🛡️Designed for GDPR
🧪In beta: anything not marked Next works today