mirror of
https://github.com/plausible/analytics.git
synced 2025-01-09 03:26:52 +03:00
Disallow site creation with insufficient input (#2741)
This commit is contained in:
parent
ad3edbfb9a
commit
3417b2dd0e
@ -43,8 +43,8 @@ defmodule Plausible.Site do
|
||||
def changeset(site, attrs \\ %{}) do
|
||||
site
|
||||
|> cast(attrs, [:domain, :timezone])
|
||||
|> validate_required([:domain, :timezone])
|
||||
|> clean_domain()
|
||||
|> validate_required([:domain, :timezone])
|
||||
|> validate_format(:domain, ~r/^[-\.\\\/:\p{L}\d]*$/u,
|
||||
message: "only letters, numbers, slashes and period allowed"
|
||||
)
|
||||
|
@ -108,6 +108,18 @@ defmodule PlausibleWeb.SiteControllerTest do
|
||||
assert Repo.get_by(Plausible.Site, domain: "example.com")
|
||||
end
|
||||
|
||||
test "fails to create the site if only http:// provided", %{conn: conn} do
|
||||
conn =
|
||||
post(conn, "/sites", %{
|
||||
"site" => %{
|
||||
"domain" => "http://",
|
||||
"timezone" => "Europe/London"
|
||||
}
|
||||
})
|
||||
|
||||
assert html_response(conn, 200) =~ "can't be blank"
|
||||
end
|
||||
|
||||
test "starts trial if user does not have trial yet", %{conn: conn, user: user} do
|
||||
Plausible.Auth.User.remove_trial_expiry(user) |> Repo.update!()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user