Skip to content

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

Use GET instead of POST for logout

Uku Tahte12b9fa42c1e
diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex
index 2ec1d8a86d..78cb526646 100644
--- a/lib/plausible_web/router.ex
+++ b/lib/plausible_web/router.ex
@@ -122,7 +122,7 @@ defmodule PlausibleWeb.Router do
get "/password", AuthController, :password_form
post "/password", AuthController, :set_password
- post "/logout", AuthController, :logout
+ get "/logout", AuthController, :logout
get "/settings", AuthController, :user_settings
put "/settings", AuthController, :save_settings
delete "/me", AuthController, :delete_me
diff --git a/lib/plausible_web/templates/layout/_header.html.eex b/lib/plausible_web/templates/layout/_header.html.eex
index bada40a729..9c2c42c30e 100644
--- a/lib/plausible_web/templates/layout/_header.html.eex
+++ b/lib/plausible_web/templates/layout/_header.html.eex
@@ -39,7 +39,7 @@
<div data-dropdown style="top: 42px; right: 0px; width: 185px;" class="absolute right-0 z-10 hidden bg-white border border-gray-300 rounded shadow-md dropdown-content dark:bg-gray-800 dark:border-gray-500">
<%= link("Settings", to: "/settings", class: "block py-2 px-2 border-b border-gray-300 dark:border-gray-500 hover:bg-gray-100 dark:hover:bg-gray-900 dark:text-gray-100") %>
- <%= link("Log out", to: "/logout", method: :post, class: "block py-2 px-2 hover:bg-gray-100 dark:hover:bg-gray-900 dark:text-gray-100") %>
+ <%= link("Log out", to: "/logout", class: "block py-2 px-2 hover:bg-gray-100 dark:hover:bg-gray-900 dark:text-gray-100") %>
</div>
</div>
</li>
diff --git a/test/plausible_web/controllers/admin_auth_controller_test.exs b/test/plausible_web/controllers/admin_auth_controller_test.exs
index c3056342f5..282dac10b6 100644
--- a/test/plausible_web/controllers/admin_auth_controller_test.exs
+++ b/test/plausible_web/controllers/admin_auth_controller_test.exs
@@ -23,7 +23,7 @@ defmodule PlausibleWeb.AdminAuthControllerTest do
assert redirected_to(conn) == "/sites"
# trying logging out
- conn = post(conn, "/logout")
+ conn = get(conn, "/logout")
assert redirected_to(conn) == "/"
conn = get(conn, "/")
assert redirected_to(conn) == "/sites"