From 2cf42d6fcc7f00029e981f35f199b973092814ec Mon Sep 17 00:00:00 2001 From: Gal Tsubery <1638049+tsubery@users.noreply.github.com> Date: Sat, 21 Dec 2024 04:00:44 -0600 Subject: [PATCH] Prevent multiple emails separated by commas in email field (#6018) --- priv/templates/phx.gen.auth/schema.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/priv/templates/phx.gen.auth/schema.ex b/priv/templates/phx.gen.auth/schema.ex index 13ff8f1db5..b289b3e0b8 100644 --- a/priv/templates/phx.gen.auth/schema.ex +++ b/priv/templates/phx.gen.auth/schema.ex @@ -46,7 +46,9 @@ defmodule <%= inspect schema.module %> do defp validate_email(changeset, opts) do changeset |> validate_required([:email]) - |> validate_format(:email, ~r/^[^\s]+@[^\s]+$/, message: "must have the @ sign and no spaces") + |> validate_format(:email, ~r/^[^@,;\s]+@[^@,;\s]+$/, + message: "must have the @ sign and no spaces" + ) |> validate_length(:email, max: 160) |> maybe_validate_unique_email(opts) end