diff --git a/lib/app/ctx.ex b/lib/app/ctx.ex index 772562bf..bbe9ecfe 100644 --- a/lib/app/ctx.ex +++ b/lib/app/ctx.ex @@ -202,102 +202,6 @@ defmodule App.Ctx do Status.changeset(status, %{}) end - alias App.Ctx.Item - - @doc """ - Returns the list of items. - - ## Examples - - iex> list_items() - [%Item{}, ...] - - """ - def list_items do - Repo.all(Item) - end - - @doc """ - Gets a single item. - - Raises `Ecto.NoResultsError` if the Item does not exist. - - ## Examples - - iex> get_item!(123) - %Item{} - - iex> get_item!(456) - ** (Ecto.NoResultsError) - - """ - def get_item!(id), do: Repo.get!(Item, id) - - @doc """ - Creates a item. - - ## Examples - - iex> create_item(%{field: value}) - {:ok, %Item{}} - - iex> create_item(%{field: bad_value}) - {:error, %Ecto.Changeset{}} - - """ - def create_item(attrs \\ %{}) do - %Item{} - |> Item.changeset(attrs) - |> Repo.insert() - end - - @doc """ - Updates a item. - - ## Examples - - iex> update_item(item, %{field: new_value}) - {:ok, %Item{}} - - iex> update_item(item, %{field: bad_value}) - {:error, %Ecto.Changeset{}} - - """ - def update_item(%Item{} = item, attrs) do - item - |> Item.changeset(attrs) - |> Repo.update() - end - - @doc """ - Deletes a Item. - - ## Examples - - iex> delete_item(item) - {:ok, %Item{}} - - iex> delete_item(item) - {:error, %Ecto.Changeset{}} - - """ - def delete_item(%Item{} = item) do - Repo.delete(item) - end - - @doc """ - Returns an `%Ecto.Changeset{}` for tracking item changes. - - ## Examples - - iex> change_item(item) - %Ecto.Changeset{source: %Item{}} - - """ - def change_item(%Item{} = item) do - Item.changeset(item, %{}) - end - alias App.Ctx.List @doc """ diff --git a/lib/app/ctx/session.ex b/lib/app/ctx/session.ex deleted file mode 100644 index 1c80e518..00000000 --- a/lib/app/ctx/session.ex +++ /dev/null @@ -1,23 +0,0 @@ -# defmodule App.Ctx.Session do -# use Ecto.Schema -# import Ecto.Changeset - -# schema "sessions" do -# field :auth_token, Fields.Encrypted -# field :refresh_token, Fields.Encrypted -# field :key_id, :integer - -# belongs_to :person, App.Ctx.Person -# timestamps() -# end - -# def changeset(people, attrs) do -# Ecto.build_assoc(people, :sessions) -# |> cast(attrs, [:auth_token, :refresh_token]) -# |> validate_required([:auth_token, :refresh_token]) -# end - -# def basic_changeset(people, _attrs) do -# Ecto.build_assoc(people, :sessions) -# end -# end diff --git a/lib/app_web/router.ex b/lib/app_web/router.ex index 827d099a..4cf39dfa 100644 --- a/lib/app_web/router.ex +++ b/lib/app_web/router.ex @@ -8,7 +8,7 @@ defmodule AppWeb.Router do plug :fetch_flash plug :protect_from_forgery plug :put_secure_browser_headers - # plug AppWeb.Auth + plug AuthPlugOptional end pipeline :api do @@ -21,10 +21,8 @@ defmodule AppWeb.Router do plug :accepts, ["json"] end - pipeline :auth_optional, do: plug(AuthPlugOptional, %{}) - scope "/", AppWeb do - pipe_through [:browser, :auth_optional] + pipe_through [:browser] get "/", PageController, :index # post "/register", PageController, :index