Legal engine

When the legal terms change, a signed-in person must accept them again. The Legal engine sends them to the page where they do that.

What it does
Checks after sign-in whether new legal terms must be accepted, and sends the person to davidnet.net to accept them.
Exported from the package?
No. enforceLegalAcceptance is not exported: afterIdentityInit of the Init engine calls it inside AppShell.

Which one do I use?

What I needUse
Check for new legal termsenforceLegalAcceptance
Know when the check runsinit

enforceLegalAcceptance

typescript
typescript
// Not exported: afterIdentityInit calls it
async function enforceLegalAcceptance(): Promise<void>

enforceLegalAcceptance() asks the backend (/legal/status) whether the signed-in person still has to accept new terms. If so, the browser goes to https://davidnet.net/legal/accept with the current page as continue, so the person comes back after accepting. It does nothing when no one is signed in, in a development build, on davidnet.net and account.davidnet.net, and on a page under /legal/accept. A request that fails is logged and does not block the person.

When to use

Nothing to do in an app with AppShell: it runs for you after sign-in.

When not to use, and what to use instead

It is not exported, so you cannot call it or turn it off. Do not build a second acceptance check: the backend decides what must be accepted. Signed out, no check is made.

Live example

Checking the session…
CallResult
authState.isLoggedInfalse
import.meta.env.DEVfalse
window.location.hostname""
hostname is davidnet.net or account.davidnet.netfalse
Result On this page the check does not run. It needs someone signed in, a production build, and a host that is not davidnet.net or account.davidnet.net.
Nothing here calls the backend or redirects you: the table shows the conditions that the engine checks, read now.
typescript
typescript
// Inside afterIdentityInit, for a signed-in person:
await enforceLegalAcceptance();

// What it does when new terms must be accepted:
window.location.href = "https://davidnet.net/legal/accept?continue=" + encodeURIComponent(currentUrl);