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:
parent
c06493e896
commit
b5e0d41756
@ -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} ->
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user