View Source LiveGuard (Live Guard v0.1.2)
A simple module with on_mount/4
callback. This can used in Phoenix LiveView applications.
The main goal is to protect the Phoenix LiveView lifecycle stages easily.
It uses the attach_hook/4
function to authorize all attachable LiveView lifecycle stages.
Summary
Functions
This macro can be used with @before_compile
hook.
This macro can be used with @before_compile
hook.
You can find the documentation of on_mount/1
here.
Functions
This macro can be used with @before_compile
hook.
It will add a catch-all allowed?/4
function returning true
, to the end the module.
Example
defimpl LiveGuard.Allowed, for: User do
@before_compile {LiveGuard, :before_compile_allowed}
# some code...
end
This macro can be used with @before_compile
hook.
It will add a catch-all guarded_stages/1
function returning all the valid attachable LiveView lifecycle stages, to the end the module.
Example
defimpl LiveGuard.GuardedStages, for: Atom do
@before_compile {LiveGuard, :before_compile_guarded_stages}
# some code...
end
@spec on_mount(:default, map(), map(), Phoenix.LiveView.Socket.t()) :: {:cont | :halt, Phoenix.LiveView.Socket.t()}
You can find the documentation of on_mount/1
here.