React to login with `UserLoggedInEvent`
Last-login tracking, role sync, audit writes.
Why three independent operations
The audit write is the only one whose failure should be surfaced — it's a compliance signal. The other two are best-effort:
- Last-login is a UX nicety; if it fails, the next login will get it right.
- Role sync from an external IDP should never block login. If Okta is down, your users still log in with cached roles.
The .catch(...) on role sync is the easiest way to fire-and-forget without unhandledRejection warnings.
Reading on login: gating an account
If the listener should be able to block the login, this is the wrong tool — listeners are post-hoc. Use the loginHooks.onLogin hook instead:
Hooks run synchronously and can throw to abort. See Hooks Reference.