forked from potsda.mn/mobilizon
Save IP and login date from directly registered accounts
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
5c43713d85
commit
1db5c4ae2d
|
@ -152,11 +152,18 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
|
|||
- send a validation email to the user
|
||||
"""
|
||||
@spec create_user(any, %{email: String.t()}, any) :: {:ok, User.t()} | {:error, String.t()}
|
||||
def create_user(_parent, %{email: email} = args, _resolution) do
|
||||
def create_user(_parent, %{email: email} = args, %{context: context}) do
|
||||
current_ip = Map.get(context, :ip)
|
||||
user_agent = Map.get(context, :user_agent, "")
|
||||
now = DateTime.utc_now()
|
||||
|
||||
with {:ok, email} <- lowercase_domain(email),
|
||||
:registration_ok <- check_registration_config(email),
|
||||
:not_deny_listed <- check_registration_denylist(email),
|
||||
{:ok, %User{} = user} <- Users.register(%{args | email: email}) do
|
||||
{:ok, %User{} = user} <-
|
||||
args
|
||||
|> Map.merge(%{email: email, current_sign_in_ip: current_ip, current_sign_in_at: now})
|
||||
|> Users.register() do
|
||||
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en"))
|
||||
{:ok, user}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue