Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Add ability to delete account and start over in activate flow

Uku Tahtc97043e191a0
diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.ex
index 5db18df231..ab8d85bdc0 100644
--- a/lib/plausible_web/controllers/auth_controller.ex
+++ b/lib/plausible_web/controllers/auth_controller.ex
@@ -377,11 +377,13 @@ defmodule PlausibleWeb.AuthController do
logout(conn, params)
end
- def logout(conn, _params) do
+ def logout(conn, params) do
+ redirect_to = Map.get(params, "redirect", "/")
+
conn
|> configure_session(drop: true)
|> delete_resp_cookie("logged_in")
- |> redirect(to: "/")
+ |> redirect(to: redirect_to)
end
def google_auth_callback(conn, %{"code" => code, "state" => site_id}) do
diff --git a/lib/plausible_web/plugs/require_account.ex b/lib/plausible_web/plugs/require_account.ex
index ee0c6ebdbc..4295a48017 100644
--- a/lib/plausible_web/plugs/require_account.ex
+++ b/lib/plausible_web/plugs/require_account.ex
@@ -14,7 +14,7 @@ defmodule PlausibleWeb.RequireAccountPlug do
|> Phoenix.Controller.redirect(to: "/login")
|> halt
- not user.email_verified and conn.path_info != ["activate"] ->
+ not user.email_verified and conn.path_info not in [["activate"], ["me"]] ->
conn
|> Phoenix.Controller.redirect(to: "/activate")
|> halt
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index 78cb526646..8dc0d82328 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -95,7 +95,7 @@ defmodule PlausibleWeb.Router do
end
scope "/", PlausibleWeb do
- pipe_through :browser
+ pipe_through [:browser, :csrf]
get "/register", AuthController, :register_form
post "/register", AuthController, :register
diff --git a/lib/plausible_web/templates/auth/activate.html.eex b/lib/plausible_web/templates/auth/activate.html.eex
index 806ab6f910..3f84ced067 100644
--- a/lib/plausible_web/templates/auth/activate.html.eex
+++ b/lib/plausible_web/templates/auth/activate.html.eex
@@ -18,11 +18,19 @@
<div class="mt-16 text-sm dark:text-gray-100">
Didn't receive an email?
</div>
- <ol class="list-decimal text-xs text-gray-500 leading-tight space-y-1 mt-1">
+ <ol class="list-disc text-xs text-gray-500 leading-tight space-y-1 mt-1">
<li>Check your spam folder</li>
<li><%= link("Send a new code", class: "underline text-indigo-600", to: "/activate/request-code", method: :post) %> to <%= @conn.assigns[:current_user].email %></li>
<li>Contact <a class="underline text-indigo-600" href="mailto:[email protected]">[email protected]</a> if the problem persists</li>
</ol>
+ <div class="mt-4 text-sm dark:text-gray-100">
+ Entered the wrong email address?
+ </div>
+ <ul class="list-disc text-xs text-gray-500 leading-tight mt-1">
+ <li>
+ <%= link("Delete this account", class: "underline text-indigo-600", to: "/me?redirect=/register", method: "delete", data: [confirm: "Deleting your account cannot be reversed. Are you sure?"]) %> and start over
+ </li>
+ </ul>
<% end %>
<% else %>
<div class="w-full max-w-lg mx-auto bg-white dark:bg-gray-800 shadow-md rounded px-8 py-6 mb-4 mt-8">