2020-01-26 20:36:50 +00:00
|
|
|
defmodule Mobilizon.Web.Auth.ErrorHandler do
|
2018-01-14 16:56:50 +00:00
|
|
|
@moduledoc """
|
|
|
|
In case we have an auth error
|
|
|
|
"""
|
2017-12-09 13:58:37 +00:00
|
|
|
import Plug.Conn
|
2023-03-17 17:10:59 +00:00
|
|
|
require Logger
|
2017-12-09 13:58:37 +00:00
|
|
|
|
2021-01-22 18:11:13 +00:00
|
|
|
# sobelow_skip ["XSS.SendResp"]
|
2021-09-28 17:40:37 +00:00
|
|
|
@spec auth_error(Plug.Conn.t(), any(), any()) :: Plug.Conn.t()
|
2023-03-17 17:10:59 +00:00
|
|
|
def auth_error(conn, {type, reason}, _opts) do
|
|
|
|
body = Jason.encode!(%{message: to_string(type), details: inspect(reason)})
|
2017-12-09 13:58:37 +00:00
|
|
|
send_resp(conn, 401, body)
|
|
|
|
end
|
2018-01-14 16:56:50 +00:00
|
|
|
end
|