diff --git a/lib/kmxgit_web.ex b/lib/kmxgit_web.ex
index d24f5cf..4511e06 100644
--- a/lib/kmxgit_web.ex
+++ b/lib/kmxgit_web.ex
@@ -25,6 +25,13 @@ defmodule KmxgitWeb do
import KmxgitWeb.Gettext
alias KmxgitWeb.ErrorView
alias KmxgitWeb.Router.Helpers, as: Routes
+
+ def not_found(conn, _params \\ %{}) do
+ conn
+ |> put_status(:not_found)
+ |> put_view(ErrorView)
+ |> render(:"404")
+ end
end
end
diff --git a/lib/kmxgit_web/controllers/admin/organisation_controller.ex b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
index 69fa453..dace002 100644
--- a/lib/kmxgit_web/controllers/admin/organisation_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/organisation_controller.ex
@@ -47,13 +47,6 @@ defmodule KmxgitWeb.Admin.OrganisationController do
end
end
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def show(conn, params) do
org = OrganisationManager.get_organisation(params["id"])
if org do
diff --git a/lib/kmxgit_web/controllers/admin/repository_controller.ex b/lib/kmxgit_web/controllers/admin/repository_controller.ex
index ab28010..6c0964a 100644
--- a/lib/kmxgit_web/controllers/admin/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/repository_controller.ex
@@ -70,13 +70,6 @@ defmodule KmxgitWeb.Admin.RepositoryController do
end
end
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def show(conn, params) do
repo = RepositoryManager.get_repository!(params["id"])
conn
diff --git a/lib/kmxgit_web/controllers/admin/user_controller.ex b/lib/kmxgit_web/controllers/admin/user_controller.ex
index 94f5116..2eec94c 100644
--- a/lib/kmxgit_web/controllers/admin/user_controller.ex
+++ b/lib/kmxgit_web/controllers/admin/user_controller.ex
@@ -18,13 +18,6 @@ defmodule KmxgitWeb.Admin.UserController do
show_user(conn, user)
end
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
defp show_user(conn, nil) do
not_found(conn)
end
@@ -76,22 +69,16 @@ defmodule KmxgitWeb.Admin.UserController do
end
def delete(conn, params) do
- user = UserManager.get_user(params["id"])
- delete_user(conn, user)
- end
-
- defp delete_user(conn, nil) do
- not_found(conn)
- end
-
- defp delete_user(conn, user) do
- {:ok, _} = UserManager.delete_user(user)
- case GitManager.update_auth() do
- :ok -> nil
- error -> IO.inspect(error)
+ if user = UserManager.get_user(params["id"]) do
+ {:ok, _} = UserManager.delete_user(user)
+ case GitManager.update_auth() do
+ :ok -> nil
+ error -> IO.inspect(error)
+ end
+ conn
+ |> redirect(to: Routes.admin_user_path(conn, :index))
+ else
+ not_found(conn)
end
- conn
- |> redirect(to: Routes.admin_user_path(conn, :index))
end
-
end
diff --git a/lib/kmxgit_web/controllers/organisation_controller.ex b/lib/kmxgit_web/controllers/organisation_controller.ex
index a538b56..f64a7cb 100644
--- a/lib/kmxgit_web/controllers/organisation_controller.ex
+++ b/lib/kmxgit_web/controllers/organisation_controller.ex
@@ -29,13 +29,6 @@ defmodule KmxgitWeb.OrganisationController do
end
end
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def edit(conn, params) do
current_user = conn.assigns.current_user
org = OrganisationManager.get_organisation_by_slug(params["slug"])
diff --git a/lib/kmxgit_web/controllers/repository_controller.ex b/lib/kmxgit_web/controllers/repository_controller.ex
index c050690..e26d4ee 100644
--- a/lib/kmxgit_web/controllers/repository_controller.ex
+++ b/lib/kmxgit_web/controllers/repository_controller.ex
@@ -92,13 +92,6 @@ defmodule KmxgitWeb.RepositoryController do
end
end
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def show(conn, params) do
current_user = conn.assigns.current_user
chunks = params["slug"] |> chunk_path()
diff --git a/lib/kmxgit_web/controllers/slug_controller.ex b/lib/kmxgit_web/controllers/slug_controller.ex
index d149111..056f5f8 100644
--- a/lib/kmxgit_web/controllers/slug_controller.ex
+++ b/lib/kmxgit_web/controllers/slug_controller.ex
@@ -8,13 +8,6 @@ defmodule KmxgitWeb.SlugController do
alias KmxgitWeb.OrganisationView
alias KmxgitWeb.UserView
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def show(conn, params) do
slug = SlugManager.get_slug(params["slug"])
if !slug do
diff --git a/lib/kmxgit_web/controllers/user_controller.ex b/lib/kmxgit_web/controllers/user_controller.ex
index 0336b7a..58d49ff 100644
--- a/lib/kmxgit_web/controllers/user_controller.ex
+++ b/lib/kmxgit_web/controllers/user_controller.ex
@@ -7,13 +7,6 @@ defmodule KmxgitWeb.UserController do
alias Kmxgit.UserManager.User
alias KmxgitWeb.ErrorView
- defp not_found(conn) do
- conn
- |> put_status(:not_found)
- |> put_view(ErrorView)
- |> render(:"404")
- end
-
def edit(conn, params) do
current_user = conn.assigns.current_user
if params["login"] == current_user.slug.slug do