diff --git a/lib/plausible/sites.ex b/lib/plausible/sites.ex index 6b34c721d..6a2b783d7 100644 --- a/lib/plausible/sites.ex +++ b/lib/plausible/sites.ex @@ -20,7 +20,9 @@ defmodule Plausible.Sites do from(s in Plausible.Site, left_join: sm in assoc(s, :memberships), left_join: i in assoc(s, :invitations), - where: sm.user_id == ^user.id or i.email == ^user.email, + where: + (is_nil(i.id) and sm.user_id == ^user.id) or + (not is_nil(i.id) and i.email == ^user.email), select: %{ s | list_type: