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.
enforceLegalAcceptanceis not exported:afterIdentityInitof the Init engine calls it inside AppShell.
Which one do I use?
| What I need | Use |
|---|---|
| Check for new legal terms | enforceLegalAcceptance |
| Know when the check runs | init |
enforceLegalAcceptance
// 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
| Call | Result |
|---|---|
| authState.isLoggedIn | false |
| import.meta.env.DEV | false |
| window.location.hostname | "" |
| hostname is davidnet.net or account.davidnet.net | false |
// 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);