Behavior for customizing dashboard access and user identification.
Host applications can implement this behavior to control who can access the dashboard, identify users, and customize refresh rates.
Example
defmodule MyApp.AludelResolver do
@behaviour Aludel.Web.Resolver
@impl true
def resolve_user(conn) do
conn.assigns[:current_user]
end
@impl true
def resolve_access(user) do
if user && user.role == :admin, do: :all, else: :read_only
end
@impl true
def resolve_refresh(_user) do
15
end
endThen configure it in your router:
use Aludel.Web, :router,
resolver: MyApp.AludelResolverDefault Behavior
If no custom resolver is configured, the defaults are:
resolve_user/1returnsnilresolve_access/1returns:allresolve_refresh/1returns5
Summary
Callbacks
Resolves the access level for a user.
Resolves the refresh interval in seconds for a user.
Resolves the current user from the connection.
Functions
Calls a resolver callback with fallback to default implementation.
Callbacks
@callback resolve_access(user :: term()) :: :all | :read_only
Resolves the access level for a user.
Return :all for full access or :read_only for restricted access.
@callback resolve_refresh(user :: term()) :: pos_integer()
Resolves the refresh interval in seconds for a user.
@callback resolve_user(conn :: Plug.Conn.t()) :: term()
Resolves the current user from the connection.
Return nil if no user is authenticated.
Functions
Calls a resolver callback with fallback to default implementation.
If the resolver module implements the callback, it is called with the given args. Otherwise, the default implementation is used.