View Source LiveGuard (Live Guard v0.1.4)
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
Optional
This macro can be used with @before_compile
hook.
Optional
This macro can be used with @before_compile
hook.
You can find the documentation of on_mount/1
here.
Types
@type attachable_lifecycle_stages() ::
:handle_params | :handle_event | :handle_info | :after_render
All the attachable LiveView lifecycle stages.
Functions
Optional
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
Optional
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( on_mount_name :: :default, params :: map(), session :: map(), socket :: Phoenix.LiveView.Socket.t() ) :: {:cont | :halt, Phoenix.LiveView.Socket.t()}
You can find the documentation of on_mount/1
here.