Handle validated users without profiles

Signed-off-by: Thomas Citharel <tcit@tcit.fr>

Format

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-01-30 15:54:21 +01:00
parent 681653e035
commit ce65c992d3
6 changed files with 34 additions and 13 deletions

View File

@@ -77,8 +77,12 @@ defmodule MobilizonWeb.Resolvers.Person do
else
{:error, :user_not_found} ->
{:error, "User with email not found"}
{:no_actor, _} ->
{:error, "You already have a profile for this user"}
{:error, %Ecto.Changeset{} = e} ->
{:error, e}
end
end
end

View File

@@ -63,7 +63,7 @@ defmodule MobilizonWeb.Resolvers.User do
{:get_actor, actor} <- {:get_actor, Actors.get_actor_for_user(user)},
{:guardian_encode_and_sign, {:ok, token, _}} <-
{:guardian_encode_and_sign, MobilizonWeb.Guardian.encode_and_sign(user)} do
{:ok, %{token: token, user: user, person: actor}}
{:ok, %{token: token, user: Map.put(user, :default_actor, actor)}}
else
err ->
Logger.info("Unable to validate user with token #{token}")