defmodule Officetournament.LoginController do
  use Officetournament.Web, :controller

  alias Officetournament.Login

  plug :scrub_params, "login" when action in [:create, :update]
  plug :action

  def index(conn, _params) do
    render(conn, "index.html")
  end

  def login(conn, %{"login" => %{"username" => username, "password" => password}}) do
    conn
    |> put_flash(:info, "Welcome #{username}! I like your password #{password}")
    |> redirect(to: login_path(conn, :index))
  end

  def login(conn, params) do
    conn
    |> put_flash(:info, "Access Denied")
    |> render "unauthorized.html"
  end
end

defmodule Officetournament.LoginController do
  use Officetournament.Web, :controller

  alias Officetournament.Login

  plug :scrub_params, "login" when action in [:create, :update]
  plug :action

  def index(conn, _params) do
    render(conn, "index.html")
  end

  def login(conn, %{"login" => %{"username" => username, "password" => password}}) do
    conn
    |> put_flash(:info, "Welcome #{username}! I like your password #{password}")
    |> redirect(to: login_path(conn, :index))
  end

  def login(conn, params) do
    conn
    |> put_layout(false)
    |> put_status(401)
    |> render "unauthorized.html"
  end
end

Use proper layout and status code
Use proper layout and status code

X0nic/officetournament,X0nic/officetournament