Fix changing changing email and validating new email with bad token

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-23 16:38:37 +01:00
parent faa92aebd9
commit 346d6438f8
3 changed files with 58 additions and 1 deletions

View File

@@ -389,7 +389,7 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
end
def validate_email(_parent, %{token: token}, _resolution) do
with %User{} = user <- Users.get_user_by_activation_token(token),
with {:get, %User{} = user} <- {:get, Users.get_user_by_activation_token(token)},
{:ok, %User{} = user} <-
user
|> User.changeset(%{
@@ -400,6 +400,9 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
})
|> Repo.update() do
{:ok, user}
else
{:get, nil} ->
{:error, dgettext("errors", "Invalid activation token")}
end
end