1
0
mirror of https://github.com/danbee/chess synced 2025-03-04 08:39:06 +00:00

Sign in a newly registered user

This commit is contained in:
Daniel Barber 2018-09-28 13:19:53 -04:00
parent c06493e896
commit b5e0d41756
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 4 additions and 1 deletions

View File

@ -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} ->

View File

@ -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