diff --git a/lib/chess_web/controllers/registration_controller.ex b/lib/chess_web/controllers/registration_controller.ex index 693694c..8c7f2df 100644 --- a/lib/chess_web/controllers/registration_controller.ex +++ b/lib/chess_web/controllers/registration_controller.ex @@ -1,6 +1,7 @@ defmodule ChessWeb.RegistrationController do use ChessWeb, :controller + alias Chess.Auth.Guardian alias Chess.Store.User def new(conn, _params) do @@ -12,8 +13,9 @@ defmodule ChessWeb.RegistrationController do changeset = User.changeset(%User{}, user) case Repo.insert(changeset) do - {:ok, _user} -> + {:ok, user} -> conn + |> Guardian.Plug.sign_in(user) |> put_flash(:info, "Registered successfully.") |> redirect(to: page_path(conn, :index)) {:error, changeset} -> diff --git a/test/features/registration_test.exs b/test/features/registration_test.exs index 5fba2b2..4055b43 100644 --- a/test/features/registration_test.exs +++ b/test/features/registration_test.exs @@ -13,6 +13,7 @@ defmodule Chess.Features.RegistrationTest do |> click(button("Register")) assert session |> has_text?("Registered successfully") + assert session |> has_text?("link@example.com") end test "user cannot register without a name", %{session: session} do