Fixes for Bamboo 2.0
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
d782ee37f0
commit
aa2c79d312
@ -117,8 +117,9 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
|
|||||||
@spec create_user(any, map, any) :: tuple
|
@spec create_user(any, map, any) :: tuple
|
||||||
def create_user(_parent, args, _resolution) do
|
def create_user(_parent, args, _resolution) do
|
||||||
with :registration_ok <- check_registration_config(args),
|
with :registration_ok <- check_registration_config(args),
|
||||||
{:ok, %User{} = user} <- Users.register(args) do
|
{:ok, %User{} = user} <- Users.register(args),
|
||||||
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en"))
|
{:ok, %Bamboo.Email{}} <-
|
||||||
|
Email.User.send_confirmation_email(user, Map.get(args, :locale, "en")) do
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
else
|
else
|
||||||
:registration_closed ->
|
:registration_closed ->
|
||||||
|
@ -79,13 +79,14 @@ defmodule Mobilizon.Web.Email.User do
|
|||||||
{:ok, user} <-
|
{:ok, user} <-
|
||||||
Users.update_user(user, %{
|
Users.update_user(user, %{
|
||||||
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
"confirmation_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
||||||
}) do
|
}),
|
||||||
send_confirmation_email(user, locale)
|
{:ok, %Bamboo.Email{}} <- send_confirmation_email(user, locale) do
|
||||||
Logger.info("Sent confirmation email again to #{user.email}")
|
Logger.info("Sent confirmation email again to #{user.email}")
|
||||||
{:ok, user.email}
|
{:ok, user.email}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec send_confirmation_email(User.t(), String.t()) :: {:ok, Bamboo.Email.t()} | {:error, any()}
|
||||||
def send_confirmation_email(%User{} = user, locale \\ "en") do
|
def send_confirmation_email(%User{} = user, locale \\ "en") do
|
||||||
user
|
user
|
||||||
|> Email.User.confirmation_email(locale)
|
|> Email.User.confirmation_email(locale)
|
||||||
@ -130,12 +131,11 @@ defmodule Mobilizon.Web.Email.User do
|
|||||||
"reset_password_token" => Crypto.random_string(30),
|
"reset_password_token" => Crypto.random_string(30),
|
||||||
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
"reset_password_sent_at" => DateTime.utc_now() |> DateTime.truncate(:second)
|
||||||
})
|
})
|
||||||
) do
|
),
|
||||||
mail =
|
{:ok, %Bamboo.Email{} = mail} <-
|
||||||
user_updated
|
user_updated
|
||||||
|> Email.User.reset_password_email(locale)
|
|> Email.User.reset_password_email(locale)
|
||||||
|> Email.Mailer.deliver_later()
|
|> Email.Mailer.deliver_later() do
|
||||||
|
|
||||||
{:ok, mail}
|
{:ok, mail}
|
||||||
else
|
else
|
||||||
{:error, reason} -> {:error, reason}
|
{:error, reason} -> {:error, reason}
|
||||||
|
Loading…
Reference in New Issue
Block a user