     # TODO handle error
     user
    end
-end+end

    |> send_json(%{ status: "ok", rights: rights })
  end


  @doc """
  As body, pass json like this
  {
     "name": "user-1",
     "pass": "pass-1"
  }

  Issues a token for the user, which can be used in follow up requests
  to claim to be that same user
  """
  post "/sign_in" do
    {:ok, token, claims} = Auth.Guardian.encode_and_sign(conn.body_params)

    conn
    |> put_resp_content_type("text/plain")
    |> send_json(%{ token: token })
  end


  defp get_user_for_bearer(nil), do: Auth.Rights.empty()


  plug :match
  plug :dispatch

  # One may or may not pass a Bearer token when calling this
  get "/show" do
    bearer = List.first get_req_header(conn, "authorization")
    rights = get_user_for_bearer(bearer)
