Handle cases where there is current user which is tmp user

token-login
Marcin Kulik 7 years ago
parent bce66edf00
commit 2042760abd

@ -19,7 +19,9 @@ defmodule Asciinema.SessionController do
end end
defp login(conn, logging_user) do defp login(conn, logging_user) do
case {conn.assigns.current_user, logging_user} do current_user = conn.assigns.current_user
case {current_user, logging_user} do
{nil, %User{email: nil}} -> {nil, %User{email: nil}} ->
conn conn
|> Auth.login(logging_user) |> Auth.login(logging_user)
@ -35,15 +37,18 @@ defmodule Asciinema.SessionController do
|> put_rails_flash(:notice, "Setting username and email will help you with logging in later.") |> put_rails_flash(:notice, "Setting username and email will help you with logging in later.")
|> redirect_to_edit_profile |> redirect_to_edit_profile
{%User{email: nil}, %User{email: nil}} -> {%User{email: nil}, %User{email: nil}} ->
Users.merge!(current_user, logging_user)
conn conn
|> put_rails_flash(:notice, "WATCHA GONNA DO") # TODO |> put_rails_flash(:notice, "Setting username and email will help you with logging in later.")
|> redirect(to: "/") |> redirect_to_edit_profile
{%User{email: nil}, %User{}} -> {%User{email: nil}, %User{}} ->
Users.merge!(logging_user, current_user)
conn conn
|> put_rails_flash(:notice, "WATCHA GONNA DO") # TODO |> Auth.login(logging_user)
|> redirect(to: "/") |> put_rails_flash(:notice, "Recorder token has been added to your account.")
{%User{} = u1, %User{email: nil} = u2} -> |> redirect_to_profile
Users.merge!(u1, u2) {%User{}, %User{email: nil}} ->
Users.merge!(current_user, logging_user)
conn conn
|> put_rails_flash(:notice, "Recorder token has been added to your account.") |> put_rails_flash(:notice, "Recorder token has been added to your account.")
|> redirect_to_profile |> redirect_to_profile

Loading…
Cancel
Save