Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Show better error message on duplicate domain

Uku Tahte026148fb09b
diff --git a/lib/plausible/site/schema.ex b/lib/plausible/site/schema.ex
index 07de7266e6..8dee788c0b 100644
--- a/lib/plausible/site/schema.ex
+++ b/lib/plausible/site/schema.ex
@@ -43,7 +43,10 @@ defmodule Plausible.Site do
|> validate_format(:domain, ~r/^[a-zA-Z0-9\-\.\/\:]*$/,
message: "only letters, numbers, slashes and period allowed"
)
- |> unique_constraint(:domain)
+ |> unique_constraint(:domain,
+ message:
+ "This domain has already been taken. Perhaps one of your team members registered it? If that's not the case, please contact [email protected]"
+ )
|> clean_domain
end
diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs
index 3d25b8398d..eace504eeb 100644
--- a/test/plausible_web/controllers/site_controller_test.exs
+++ b/test/plausible_web/controllers/site_controller_test.exs
@@ -259,7 +259,8 @@ defmodule PlausibleWeb.SiteControllerTest do
}
})
- assert html_response(conn, 200) =~ "has already been taken"
+ assert html_response(conn, 200) =~
+ "This domain has already been taken. Perhaps one of your team members registered it? If that's not the case, please contact [email protected]"
end
end