Created
November 25, 2018 07:33
-
-
Save hauptbenutzer/bcc528c622317aabf0b8c5ee1890c536 to your computer and use it in GitHub Desktop.
Guardian VerifyHeader Wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyAppWeb.Guardian.VerifyHeader do | |
@moduledoc """ | |
This is a wrapper for Guardian.Plug.VerifyHeader, the difference being that | |
we do not want the connection to be halted. | |
""" | |
@behaviour Plug | |
def init(opts), do: Guardian.Plug.VerifyHeader.init(opts) | |
def call(conn, opts) do | |
conn = Guardian.Plug.VerifyHeader.call(conn, opts) | |
# Since Guardian 1.x, the conn is automatically halted after being passed to the | |
# error handler. We do want it to reach the downstream plugs, so we'll unhalt it. | |
# see https://github.com/ueberauth/guardian/issues/401 | |
%{conn | halted: false} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good solution, but I added state to
%{conn | halted: false, state: :unset}
, to avoidPlug.Conn.AlreadySentError
error