Skip to content

Instantly share code, notes, and snippets.

@8zca
Last active January 19, 2020 14:15
Show Gist options
  • Save 8zca/ec5c0cf88cd43e3234fc01cc44003f05 to your computer and use it in GitHub Desktop.
Save 8zca/ec5c0cf88cd43e3234fc01cc44003f05 to your computer and use it in GitHub Desktop.
lib/phoenix_admin/accounts/user.ex
# lib/phoenix_admin/accounts/error_handler.ex
defmodule PhoenixAdmin.Accounts.ErrorHandler do
import Plug.Conn
@behaviour Guardian.Plug.ErrorHandler
@impl Guardian.Plug.ErrorHandler
def auth_error(conn, {type, _reason}, _opts) do
body = to_string(type)
conn
|> put_resp_content_type("text/plain")
|> send_resp(401, body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment