From e026148fb09b4eeffcd6e97f8dd234c6cf287585 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Thu, 10 Mar 2022 15:11:19 -0600 Subject: [PATCH] Show better error message on duplicate domain Co-authored-by: Marko Saric --- lib/plausible/site/schema.ex | 5 ++++- test/plausible_web/controllers/site_controller_test.exs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/plausible/site/schema.ex b/lib/plausible/site/schema.ex index 07de7266e..8dee788c0 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 support@plausible.io" + ) |> clean_domain end diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs index 3d25b8398..eace504ee 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 support@plausible.io" end end