Guardian.Plug.EnsureNotAuthenticated (Guardian v2.4.0)
View SourceThis plug ensures that a resource is not logged in.
If one is not found, the auth_error will be called with :already_authenticated
This, like all other Guardian plugs, requires a Guardian pipeline to be setup. It requires an implementation module, an error handler and a key.
These can be set either:
- Upstream on the connection with
plug Guardian.Pipeline - Upstream on the connection with
Guardian.Pipeline.{put_module, put_error_handler, put_key} - Inline with an option of
:module,:error_handler,:key
Options:
key- The location to find the information in the connection. Defaults to:defaulthalt- Whether to halt the connection in case of error. Defaults totrue
Example
# setup the upstream pipeline
plug Guardian.Plug.EnsureNotAuthenticated
plug Guardian.Plug.EnsureNotAuthenticated, key: :secret