Add login information to user
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -15,10 +15,10 @@ defmodule Mobilizon.Web.Auth.Context do
|
||||
def call(%{assigns: %{ip: _}} = conn, _opts), do: conn
|
||||
|
||||
def call(conn, _opts) do
|
||||
set_user_and_ip_in_context(conn)
|
||||
set_user_information_in_context(conn)
|
||||
end
|
||||
|
||||
def set_user_and_ip_in_context(conn) do
|
||||
def set_user_information_in_context(conn) do
|
||||
context = %{ip: conn.remote_ip |> :inet.ntoa() |> to_string()}
|
||||
|
||||
context =
|
||||
@@ -30,6 +30,15 @@ defmodule Mobilizon.Web.Auth.Context do
|
||||
context
|
||||
end
|
||||
|
||||
context =
|
||||
case get_req_header(conn, "user-agent") do
|
||||
[user_agent | _] ->
|
||||
Map.put(context, :user_agent, user_agent)
|
||||
|
||||
_ ->
|
||||
context
|
||||
end
|
||||
|
||||
put_private(conn, :absinthe, %{context: context})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,8 +44,6 @@ defmodule Mobilizon.Web.Auth.Guardian do
|
||||
end
|
||||
|
||||
def after_encode_and_sign(resource, claims, token, _options) do
|
||||
Logger.debug(fn -> "after_encode_and_sign #{inspect(claims)}" end)
|
||||
|
||||
with {:ok, _} <- Guardian.DB.after_encode_and_sign(resource, claims["typ"], claims, token) do
|
||||
{:ok, token}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user