Commit 19c6932e134c6c5738092bd5d1bbf8fca4fe5d33

Thomas de Grivel 2022-02-19T18:06:56

fix

diff --git a/lib/kmxgit/repository_manager.ex b/lib/kmxgit/repository_manager.ex
index 1396fc0..285efb8 100644
--- a/lib/kmxgit/repository_manager.ex
+++ b/lib/kmxgit/repository_manager.ex
@@ -21,8 +21,8 @@ defmodule Kmxgit.RepositoryManager do
     |> where([r, o, os, u, us], not is_nil(r))
     |> order_by([r, o, os, u, us], [fragment("concat(lower(?), lower(?))", os.slug, us.slug), :slug])
     |> preload([members: :slug,
-               organisation: [:slug, users: :slug],
-               user: :slug])
+                organisation: [:slug, users: :slug],
+                user: :slug])
     |> Repo.all()
   end
 
diff --git a/lib/kmxgit/user_manager.ex b/lib/kmxgit/user_manager.ex
index d4d7c00..6fc320f 100644
--- a/lib/kmxgit/user_manager.ex
+++ b/lib/kmxgit/user_manager.ex
@@ -109,7 +109,9 @@ defmodule Kmxgit.UserManager do
     Repo.one from user in User,
       where: [id: ^id],
       preload: [organisations: :slug],
-      preload: [owned_repositories: [organisation: :slug, user: :slug]],
+      preload: [owned_repositories: [members: :slug,
+                                     organisation: :slug,
+                                     user: :slug]],
       preload: :slug
   end
 
diff --git a/lib/kmxgit_web/controllers/slug_controller.ex b/lib/kmxgit_web/controllers/slug_controller.ex
index e3449d2..3c87878 100644
--- a/lib/kmxgit_web/controllers/slug_controller.ex
+++ b/lib/kmxgit_web/controllers/slug_controller.ex
@@ -35,11 +35,16 @@ defmodule KmxgitWeb.SlugController do
       else
         org = slug.organisation
         if org do
+          repos = org.repositories
+          |> Enum.filter(fn repo ->
+            repo.public_access || Repository.member?(repo, current_user)
+          end)
           conn
           |> assign(:current_organisation, org)
           |> assign(:disk_usage, Organisation.disk_usage(org))
           |> assign(:org, org)
           |> assign(:page_title, org.name || org.slug.slug)
+          |> assign(:repos, repos)
           |> put_view(OrganisationView)
           |> render("show.html")
         else