From 5545604ffc6d67bc0b12beb104da67db428654be Mon Sep 17 00:00:00 2001 From: Andrew Dryga Date: Wed, 7 Aug 2024 10:43:28 -0600 Subject: [PATCH] fix(portal): Do not allow emails with just TLD in place (#6205) `foo@bar` was a valid domain, while it's technically possible that somebody owns a TLD with MX records Stripe will not accept that, so we have to adopt this validation and make sure sign ups don't results in HTTP 500s. --- elixir/apps/domain/lib/domain/repo/changeset.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elixir/apps/domain/lib/domain/repo/changeset.ex b/elixir/apps/domain/lib/domain/repo/changeset.ex index c54047b4c..5153ec4be 100644 --- a/elixir/apps/domain/lib/domain/repo/changeset.ex +++ b/elixir/apps/domain/lib/domain/repo/changeset.ex @@ -193,7 +193,7 @@ defmodule Domain.Repo.Changeset do def validate_email(%Ecto.Changeset{} = changeset, field) do changeset - |> validate_format(field, ~r/^[^\s]+@[^\s]+$/, message: "is an invalid email address") + |> validate_format(field, ~r/^[^\s]+@[^\s]+\.[^\s]+$/, message: "is an invalid email address") |> validate_length(field, max: 160) end