ETS cache of who a signed-in user is to the site gates: their site, their address and the names of
the permissions they hold, and whether they are a dashboard admin and an API admin
(MishkaCmsCore.Accounts.Helper.dashboard_admin?/1 and api_admin?/1). A request that has not
loaded its user — a file, a live navigation — is answered from here by the user's id, with no
query, and every Helper admin predicate and MishkaCmsCore.Accounts.AuthGate.signs_out?/2
answer a cached viewer exactly as they answer the user.
An entry is written by the page pipeline, which loads the user fresh on every request, and is
dropped whenever that user's access changes: MishkaCmsCore.Accounts.LiveSockets.disconnect/1 calls
forget/1, which clears it on every node. A user with no entry is answered as someone who is not
an admin until their next page load writes one, so a gap closes rather than opens.
Each write and drop is announced on runtime:state:viewer:changed as %{op: :save | :delete, key: user_id}, once per node.
Summary
Functions
Returns a specification to start this module under a supervisor.
Drops a user's entry on every node.
The cached viewer for a user id, or nil.
Writes user as the gates should see them, when it differs from what is cached.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec forget(String.t()) :: :ok
Drops a user's entry on every node.
The cached viewer for a user id, or nil.
@spec remember(map() | nil) :: :ok
Writes user as the gates should see them, when it differs from what is cached.