Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Do not error when activating an account that already exists (#370)
Uku Tahtdd44bc803d16
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 54daa3d22b..1af1425a16 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,6 +1,11 @@# ChangelogAll notable changes to this project will be documented in this file.+## [1.1.2] - 2020-10-14++### Fixed+- Do not error when activating an already activated account plausible/analytics#370+## [1.1.1] - 2020-10-14### Fixeddiff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.exindex 989845fc75..25c12eba91 100644--- a/lib/plausible_web/controllers/auth_controller.ex+++ b/lib/plausible_web/controllers/auth_controller.ex@@ -65,11 +65,10 @@ defmodule PlausibleWeb.AuthController doPlausibleWeb.Email.welcome_email(user)|> Plausible.Mailer.send_email()- conn- |> put_session(:current_user_id, user.id)- |> put_resp_cookie("logged_in", "true", http_only: false)- |> redirect(to: "/password")-+ user_activated_account(conn, user)+ {:error, %Ecto.Changeset{errors: [email: {"has already been taken", _}]}} ->+ user = Auth.find_user_by(email: email)+ user_activated_account(conn, user){:error, changeset} ->send_resp(conn, 400, inspect(changeset.errors))end@@ -82,6 +81,13 @@ defmodule PlausibleWeb.AuthController doendend+ defp user_activated_account(conn, user) do+ conn+ |> put_session(:current_user_id, user.id)+ |> put_resp_cookie("logged_in", "true", http_only: false)+ |> redirect(to: "/password")+ end+def password_reset_request_form(conn, _) dorender(conn, "password_reset_request_form.html",layout: {PlausibleWeb.LayoutView, "focus.html"}diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exsindex f7de934359..726b2b4f12 100644--- a/test/plausible_web/controllers/auth_controller_test.exs+++ b/test/plausible_web/controllers/auth_controller_test.exs@@ -56,13 +56,13 @@ defmodule PlausibleWeb.AuthControllerTest doassert redirected_to(conn) == "/password"end- test "shows error when user with that email already exists", %{conn: conn} do+ test "redirects existing user to create a password", %{conn: conn} dotoken = Plausible.Auth.Token.sign_activation("Jane Doe", "[email protected]")conn = get(conn, "/claim-activation?token=#{token}")conn = get(conn, "/claim-activation?token=#{token}")- assert conn.status == 400+ assert redirected_to(conn) == "/password"endend