Monitorex.Resolver behaviour
(monitorex v0.3.0)
Copy Markdown
Behaviour for resolving the current user and their access level in the Monitorex dashboard.
Implement this module in your application and configure it via:
config :monitorex, :resolver, MyApp.MonitorexResolverCallbacks
resolve_user/1— receives aPlug.Conn.t()and returns a user struct (any shape). The user is stored in the LiveView socket assigns as:current_user.resolve_access/1— receives the user struct returned byresolve_user/1and returns one of::all— full access (read + write):read_only— read-only access{:forbidden, path}— redirect user to the given path
resolve_refresh/1— optional. Receives aPlug.Conn.t()and returns a (possibly modified) conn. Called after access is resolved, useful for extending the session lifetime.
Summary
Callbacks
Resolves the access level for the given user.
Optional callback to refresh the connection (e.g., extend session).
Resolves the current user from the Plug connection. Returns a user struct of any shape.
Callbacks
Resolves the access level for the given user.
Returns :all, :read_only, or {:forbidden, redirect_path}.
@callback resolve_refresh(conn :: Plug.Conn.t()) :: Plug.Conn.t()
Optional callback to refresh the connection (e.g., extend session).
@callback resolve_user(conn :: Plug.Conn.t()) :: map()
Resolves the current user from the Plug connection. Returns a user struct of any shape.