 
   require Logger
 
-  @type current_user :: User.t() | atom
-
-  @doc """
-  Adds a third argument to every action that contains the current user or the atom `:guest`.
-
-  Runs before all other actions in the controller.
-  """
-  @spec action(Plug.Conn.t(), Map.t()) :: Plug.Conn.t()
-  def action(conn, params)
-
-  def action(conn, _) do
-    args = [conn, conn.params, conn.assigns[:current_user] || :guest]
-    apply(__MODULE__, action_name(conn), args)
-  end
-
   @doc """
   Creates a new tweak with the given parameters.
   """
-  @spec create(Plug.Conn.t(), Map.t(), current_user) :: Plug.Conn.t()
-  def create(conn, params, current_user)
+  @spec create(Plug.Conn.t(), Map.t()) :: Plug.Conn.t()
+  def create(conn, params)
 
-  def create(conn, _, :guest), do: raise(NotLoggedInError, conn: conn)
+  def create(conn = %{assigns: %{current_user: nil}}, _), do: raise(NotLoggedInError, conn: conn)
 
-  def create(conn, %{"tweak" => tweak_params}, current_user) do
+  def create(conn, %{"tweak" => tweak_params}) do
+    current_user = conn.assigns.current_user
     params = Map.merge(tweak_params, %{"created_by" => current_user.id})
     changeset = Tweak.changeset(%Tweak{}, params)
 


  **Not implemented.**
  """
  @spec delete(Plug.Conn.t(), Map.t(), current_user) :: Plug.Conn.t()
  def delete(conn, _params, _current_user) do
    conn
  end

  @doc """
  Displays the edit tweak form.
  """
  @spec edit(Plug.Conn.t(), Map.t(), current_user) :: Plug.Conn.t()
  def edit(conn, params, current_user)

  def edit(conn, _, :guest), do: raise(NotLoggedInError, conn: conn)

  def edit(conn, %{"id" => id}, current_user) do
    tweak =
      Tweak
      |> Repo.get(id)

defmodule AtomTweaksWeb.TweakController do
  use AtomTweaksWeb, :controller

  alias AtomTweaks.Tweaks
  alias AtomTweaks.Tweaks.Tweak
  alias AtomTweaksWeb.NotLoggedInError
