   alias OpenPantry.UserCredit
   alias OpenPantry.Facility
   import OpenPantry.Web.UserSelectionView, only: [login_token: 1]
-  @hardcoded_facility_id 1
   @unknown_language_id 184
 
   def index(conn, _params) do
-    facility = Facility.find(@hardcoded_facility_id, :users)
+    facility = facility(conn) |> Repo.preload(:users)
     render conn, "index.html",  users: facility.users, conn: conn, changeset: User.changeset(%User{})
   end
 

    end
  end


  defp redirect_and_notify(conn, user) do
    conn

    user =  User.changeset(%User{}, %{name: name_from_params(params),
                                      family_members: family_members_from_params(params),
                                      primary_language_id: @unknown_language_id,
                                      facility_id: facility(conn).id,
                                     })
            |> Repo.insert!()

