Make tests great again !

(Also use only one field for public/private key pem)
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2018-06-14 17:25:55 +02:00
parent 32596c3624
commit ca36dd12e2
43 changed files with 498 additions and 656 deletions

View File

@@ -16,16 +16,11 @@ defmodule EventosWeb.UserController do
end
def register(conn, %{"username" => username, "email" => email, "password" => password}) do
case Actors.register(%{email: email, password: password, username: username}) do
{:ok, %User{} = user} ->
{:ok, token, _claims} = EventosWeb.Guardian.encode_and_sign(user)
with {:ok, %User{} = user} <- Actors.register(%{email: email, password: password, username: username}),
{:ok, token, _claims} <- EventosWeb.Guardian.encode_and_sign(user) do
conn
|> put_status(:created)
|> render("show_with_token.json", %{token: token, user: user})
{:error, error} ->
conn
|> put_resp_content_type("application/json")
|> send_resp(400, Poison.encode!(%{"msg" => handle_changeset_errors(error)}))
end
end