Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ extend-exclude = [
"**/*.xml",
"**/*.html",
"tracker/eslint.config.mjs",
# Vendored list of domain names (not prose), regenerated upstream
"priv/disposable_email_domains.txt",
# Already-shipped migrations
"priv/repo/migrations/20200227092821_add_fingerprint_sesssions.exs",
"priv/repo/migrations/20231219083050_track_accept_traffic_until_notifcations.exs",
Expand Down
55 changes: 0 additions & 55 deletions extra/lib/plausible/auth/disposable_email.ex

This file was deleted.

8 changes: 2 additions & 6 deletions extra/lib/plausible/auth/sso.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ defmodule Plausible.Auth.SSO do

@spec provision_user(SSO.Identity.t()) ::
{:ok, :standard | :sso | :integration, Teams.Team.t(), Auth.User.t()}
| {:error, :integration_not_found | :over_limit | :disposable_email}
| {:error, :integration_not_found | :over_limit}
| {:error, :multiple_memberships | :active_personal_team, Teams.Team.t(), Auth.User.t()}
def provision_user(identity) do
case find_user(identity) do
Expand All @@ -92,11 +92,7 @@ defmodule Plausible.Auth.SSO do
provision_sso_user(user, identity, integration, domain)

{:ok, :integration, _, integration, domain} ->
# Only a brand new user has their email "entered" here. Existing users
# are matched by the email they already have.
with :ok <- Teams.Invitations.ensure_not_disposable_email(identity.email) do
provision_identity(identity, integration, domain)
end
provision_identity(identity, integration, domain)

{:error, :not_found} ->
{:error, :integration_not_found}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ defmodule PlausibleWeb.Api.ExternalSitesController do
email: invitation.team_invitation.email,
status: "invited"
})

{:error, :disposable_email} ->
H.bad_request(conn, "Disposable email addresses are not allowed")
end
end
else
Expand Down
12 changes: 0 additions & 12 deletions lib/plausible/auth/auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,18 +297,6 @@ defmodule Plausible.Auth do
def super_admin?(_), do: always(false)
end

@doc """
Whether the email is on a disposable (throwaway) email domain.

This is the single entry point for the check, always `false` on Community Edition.
"""
@spec disposable_email?(String.t() | nil) :: boolean()
on_ee do
def disposable_email?(email), do: Auth.DisposableEmail.disposable?(email)
else
def disposable_email?(_), do: always(false)
end

@spec list_api_keys(Auth.User.t(), Teams.Team.t() | nil) :: [Auth.ApiKey.t()]
def list_api_keys(user, team) do
query =
Expand Down
16 changes: 0 additions & 16 deletions lib/plausible/auth/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ defmodule Plausible.Auth.User do
use Ecto.Schema
import Ecto.Changeset

alias Plausible.Auth

@type t() :: %__MODULE__{}

@required [:email, :name, :password]
Expand Down Expand Up @@ -85,7 +83,6 @@ defmodule Plausible.Auth.User do
|> validate_required(:name, message: "Please enter your name")
|> validate_required(:email, message: "Please enter your email")
|> validate_required(:password, message: "Please enter a password")
|> validate_email_not_disposable()
|> validate_password_length()
|> validate_password_strength()
|> hash_password()
Expand Down Expand Up @@ -117,7 +114,6 @@ defmodule Plausible.Auth.User do
|> cast(attrs, [:email, :password])
|> validate_required([:email, :password])
|> validate_email_changed()
|> validate_email_not_disposable()
|> check_password()
|> unique_constraint(:email)
|> set_email_verification_status()
Expand Down Expand Up @@ -218,18 +214,6 @@ defmodule Plausible.Auth.User do
profile_img_url(%__MODULE__{email: email})
end

# Applied to email changes as well as signups: otherwise an address could be freed
# up for re-registration by switching the account to a disposable one.
defp validate_email_not_disposable(changeset) do
validate_change(changeset, :email, fn :email, email ->
if Auth.disposable_email?(email) do
[email: {"Disposable email addresses are not allowed", validation: :disposable_email}]
else
[]
end
end)
end

defp validate_email_changed(changeset) do
if !get_change(changeset, :email) && !changeset.errors[:email] do
add_error(changeset, :email, "can't be the same", validation: :different_email)
Expand Down
9 changes: 0 additions & 9 deletions lib/plausible/teams/invitations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,6 @@ defmodule Plausible.Teams.Invitations do
:ok
end

@doc false
def ensure_not_disposable_email(email) do
if Auth.disposable_email?(email) do
{:error, :disposable_email}
else
:ok
end
end

@doc false
def check_team_member_limit(_team, :owner, _invitee_email), do: :ok

Expand Down
2 changes: 0 additions & 2 deletions lib/plausible/teams/invitations/invite_to_site.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ defmodule Plausible.Teams.Invitations.InviteToSite do
@type invite_error() ::
Ecto.Changeset.t()
| :already_a_member
| :disposable_email
| {:over_limit, non_neg_integer()}
| :permission_denied

Expand All @@ -35,7 +34,6 @@ defmodule Plausible.Teams.Invitations.InviteToSite do
defp do_invite(site, inviter, invitee_email, role) do
with site <- Repo.preload(site, [:owners, :team]),
:ok <- Teams.TeamRolePermissions.ensure_can_manage_team(site.team, inviter),
:ok <- Teams.Invitations.ensure_not_disposable_email(invitee_email),
:ok <- Teams.Invitations.check_team_member_limit(site.team, role, invitee_email),
invitee = Plausible.Auth.find_user_by(email: invitee_email),
:ok <- Teams.Invitations.ensure_new_membership(site, invitee, role),
Expand Down
9 changes: 3 additions & 6 deletions lib/plausible/teams/invitations/invite_to_team.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule Plausible.Teams.Invitations.InviteToTeam do

use Plausible

alias Plausible.Auth
alias Plausible.Repo
alias Plausible.Teams

Expand All @@ -15,10 +14,9 @@ defmodule Plausible.Teams.Invitations.InviteToTeam do
Creates team invitations for all given entries in a single transaction.
Either all of them get created, or none. Does not send any emails yet.

Returns `{:error, :invalid_email}`, `{:error, :disposable_email}` or
`{:error, :duplicate_emails}` without touching the database if any of the
entries' emails is invalid or on a disposable domain (EE only), or if the
same email appears more than once.
Returns `{:error, :invalid_email}` or `{:error, :duplicate_emails}`
without touching the database if any of the entries' emails is invalid,
or if the same email appears more than once.
"""
@spec invite_all(
Teams.Team.t(),
Expand Down Expand Up @@ -61,7 +59,6 @@ defmodule Plausible.Teams.Invitations.InviteToTeam do
defp validate_emails(emails) do
cond do
not Enum.all?(emails, &valid_email?/1) -> {:error, :invalid_email}
Enum.any?(emails, &Auth.disposable_email?/1) -> {:error, :disposable_email}
# emails are case-insensitive in the database (citext)
Enum.uniq_by(emails, &String.downcase/1) != emails -> {:error, :duplicate_emails}
true -> :ok
Expand Down
3 changes: 1 addition & 2 deletions lib/plausible/teams/sites/transfer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ defmodule Plausible.Teams.Sites.Transfer do
"""
@spec initiate(Site.t(), Auth.User.t(), String.t(), NaiveDateTime.t()) ::
{:ok, Teams.SiteTransfer.t()}
| {:error, Ecto.Changeset.t() | :permission_denied | :disposable_email}
| {:error, Ecto.Changeset.t() | :permission_denied}
def initiate(site, initiator, invitee_email, now \\ NaiveDateTime.utc_now(:second)) do
site = Repo.preload(site, :team)

Repo.transaction(fn ->
with :ok <- Teams.TeamRolePermissions.ensure_can_manage_team(site.team, initiator),
:ok <- Teams.Invitations.ensure_not_disposable_email(invitee_email),
{:ok, site_transfer} <-
create_site_transfer(site, initiator, invitee_email, now) do
invitee = Auth.find_user_by(email: invitee_email)
Expand Down
7 changes: 0 additions & 7 deletions lib/plausible_web/controllers/site/membership_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ defmodule PlausibleWeb.Site.MembershipController do
skip_plausible_tracking: true
)

{:error, :disposable_email} ->
render(conn, "invite_member_form.html",
error: "Disposable email addresses are not allowed",
site: site,
skip_plausible_tracking: true
)

{:error, {:over_limit, limit}} ->
render(conn, "invite_member_form.html",
error:
Expand Down
7 changes: 0 additions & 7 deletions lib/plausible_web/live/site_transfer_settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,6 @@ defmodule PlausibleWeb.Live.SiteTransferSettings do
|> put_flash(:success, "Site transfer request has been sent to #{email}")
|> redirect(to: ~p"/#{site.domain}/settings/people")}

{:error, :disposable_email} ->
{:noreply,
assign_form(socket, params,
action: :insert,
field_errors: [{:email, "Disposable email addresses are not allowed"}]
)}

{:error, %Ecto.Changeset{} = changeset} ->
message =
case Plausible.ChangesetHelpers.traverse_errors(changeset) do
Expand Down
3 changes: 0 additions & 3 deletions lib/plausible_web/live/team_management.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ defmodule PlausibleWeb.Live.TeamManagement do
{:error, reason}
when reason in [
:invalid_email,
:disposable_email,
:already_a_member,
:invited_as_member,
:already_a_guest,
Expand Down Expand Up @@ -289,8 +288,6 @@ defmodule PlausibleWeb.Live.TeamManagement do
do:
"Make sure the e-mail is valid and not already taken by an existing member or invitation"

defp error_message(:disposable_email), do: "Disposable email addresses are not allowed"

defp error_message(:already_a_guest),
do:
"This e-mail belongs to a guest. Please change their role below, or delete and invite them again."
Expand Down
3 changes: 0 additions & 3 deletions lib/plausible_web/live/team_setup.ex
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ defmodule PlausibleWeb.Live.TeamSetup do
{:error, :invalid_email} ->
{:noreply, put_live_flash(socket, :error, "Make sure all e-mails are valid")}

{:error, :disposable_email} ->
{:noreply, put_live_flash(socket, :error, "Disposable email addresses are not allowed")}

{:error, :duplicate_emails} ->
{:noreply, put_live_flash(socket, :error, "Make sure e-mails are unique")}

Expand Down
29 changes: 11 additions & 18 deletions lib/plausible_web/user_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ defmodule PlausibleWeb.UserAuth do
|> Phoenix.Controller.redirect(to: redirect_to)

{:error, :integration_not_found} ->
sso_login_error(
conn,
"We couldn't find a Single Sign-On account for that email.",
redirect_path
conn
|> log_out_user()
|> Phoenix.Controller.put_flash(
:login_error,
"We couldn't find a Single Sign-On account for that email."
)
|> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: redirect_path]}")

{:error, :over_limit} ->
sso_login_error(
conn,
"Team can't accept more members. Please contact the owner.",
redirect_path
)
error = "Team can't accept more members. Please contact the owner."

{:error, :disposable_email} ->
sso_login_error(conn, "Disposable email addresses are not allowed.", redirect_path)
conn
|> log_out_user()
|> Phoenix.Controller.put_flash(:login_error, error)
|> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: redirect_path]}")

{:error, reason, _team, _user}
when reason in [:multiple_memberships, :active_personal_team] ->
Expand All @@ -72,13 +72,6 @@ defmodule PlausibleWeb.UserAuth do
|> Phoenix.Controller.redirect(to: ~p"/sso/issue?#{[issue: issue]}")
end
end

defp sso_login_error(conn, error, redirect_path) do
conn
|> log_out_user()
|> Phoenix.Controller.put_flash(:login_error, error)
|> Phoenix.Controller.redirect(to: ~p"/sso/login?#{[return_to: redirect_path]}")
end
end

@spec log_out_user(Plug.Conn.t()) :: Plug.Conn.t()
Expand Down
Loading
Loading