Add GraphQL support to handle FeedTokens

Closes #88

Automatically create tokens for new users and actors

Closes #89

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2019-03-08 18:52:27 +01:00
parent c61c75163f
commit 99ac6ef100
14 changed files with 541 additions and 31 deletions

View File

@@ -21,6 +21,18 @@ defmodule Mobilizon.Users do
queryable
end
@doc """
Register user
"""
@spec register(map()) :: {:ok, User.t()} | {:error, String.t()}
def register(%{email: _email, password: _password} = args) do
with {:ok, %User{} = user} <-
%User{} |> User.registration_changeset(args) |> Mobilizon.Repo.insert() do
Mobilizon.Events.create_feed_token(%{"user_id" => user.id})
{:ok, user}
end
end
@doc """
Gets an user by it's email