defmodule ToweropsWeb.PageController do
  @moduledoc false

  use ToweropsWeb, :controller

  def home(conn, _params) do
    # If user is authenticated, redirect to organization list
    if conn.assigns.current_scope && conn.assigns.current_scope.user do
      redirect(conn, to: ~p"/orgs")
    else
      render(conn, :home, layout: false)
    end
  end

  def privacy(conn, _params) do
    render(conn, :privacy,
      current_scope: conn.assigns[:current_scope],
      current_organization: conn.assigns[:current_organization]
    )
  end

  def terms(conn, _params) do
    render(conn, :terms,
      current_scope: conn.assigns[:current_scope],
      current_organization: conn.assigns[:current_organization]
    )
  end
end
