Compare commits

...
1 Commits
Author SHA1 Message Date
KKlochko 8a423b721d Add ErrorHandler for API Auth.
continuous-integration/drone/push Build is failing
continuous-integration/drone/tag Build was killed
2023-08-12 21:02:05 +03:00
2 changed files with 12 additions and 0 deletions
+2
View File
@@ -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