Add ErrorHandler for API Auth.
continuous-integration/drone/push Build is failing Details
continuous-integration/drone/tag Build was killed Details

main 0.8.4
KKlochko 2 years ago
parent 06dfee5b57
commit 8a423b721d

@ -63,3 +63,5 @@
Add the auth pipeline for the Link API path. Add the auth pipeline for the Link API path.
** 0.8.3 <2023-08-11 Fri> ** 0.8.3 <2023-08-11 Fri>
Add tests for user login. Add tests for user login.
** 0.8.4 <2023-08-12 Sat>
Add ErrorHandler for API Auth.

@ -0,0 +1,10 @@
defmodule LinkShortenerWeb.Auth.ErrorHandler do
import Plug.Conn
def auth_error(conn, {type, _reason}, _opts) do
body = Poison.encode!(%{error: to_string(type)})
conn
|> put_resp_content_type("application/json")
|> send_resp(401, body)
end
end
Loading…
Cancel
Save