Make sure that deleting an account also deletes stats

pull/1498/head
Uku Taht 5 years ago
parent 5f6553c8d8
commit 37d3f2e36e

@ -145,6 +145,11 @@ defmodule Plausible.Sites do
)
end
def delete!(site) do
Repo.delete!(site)
Plausible.ClickhouseRepo.clear_stats_for(site.domain)
end
def add_custom_domain(site, custom_domain) do
CustomDomain.changeset(%CustomDomain{}, %{
site_id: site.id,

@ -516,7 +516,7 @@ defmodule PlausibleWeb.AuthController do
Repo.delete!(membership)
if membership.role == :owner do
Repo.delete!(membership.site)
Plausible.Sites.delete!(membership.site)
end
end

@ -331,8 +331,7 @@ defmodule PlausibleWeb.SiteController do
def delete_site(conn, _params) do
site = conn.assigns[:site]
Repo.delete!(site)
Plausible.ClickhouseRepo.clear_stats_for(site.domain)
Plausible.Sites.delete!(site)
conn
|> put_flash(:success, "Site deleted successfully along with all pageviews")

@ -223,9 +223,9 @@
<p class="dark:text-gray-100">Deleting your account removes all sites and stats you've collected</p>
<%= if @subscription && @subscription.status == "active" do %>
<span class="mt-6 bg-gray-300 button dark:bg-gray-800 hover:shadow-none">Delete my account</span>
<span class="mt-6 bg-gray-300 button dark:bg-gray-800 hover:shadow-none hover:bg-gray-300">Delete my account</span>
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Your account cannot be deleted because you have an active subscription. If you want to delete your account, please cancel your subscription first.</p>
<% else %>
<%= link("Delete my account", to: "/me", class: "inline-block mt-4 px-4 py-2 border border-gray-300 dark:border-gray-500 text-sm leading-5 font-medium rounded-md text-red-700 bg-white dark:bg-gray-800 hover:text-red-500 dark:hover:text-red-400 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", method: "delete", data: [confirm: "Deleting your account will also delete all the sites that you own. This action cannot be reversed. Are you sure?"]) %>
<%= link("Delete my account", to: "/me", class: "inline-block mt-4 px-4 py-2 border border-gray-300 dark:border-gray-500 text-sm leading-5 font-medium rounded-md text-red-700 bg-white dark:bg-gray-800 hover:text-red-500 dark:hover:text-red-400 focus:outline-none focus:border-blue-300 focus:ring active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", method: "delete", data: [confirm: "Deleting your account will also delete all the sites and data that you own. This action cannot be reversed. Are you sure?"]) %>
<% end %>
</div>

Loading…
Cancel
Save