Add ability to delete account and start over in activate flow

Fixes #581
pull/907/head
Uku Taht 6 years ago
parent 1120ede0b4
commit c97043e191

@ -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

@ -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

@ -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

@ -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:support@plausible.io">support@plausible.io</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">

Loading…
Cancel
Save