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
Allow editor in Google OAuth callbacks in line with actions (#6407)
Adrian Gruntkowski5c23c1770318
diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.exindex 5b96db1015..73ab4d35dc 100644--- a/lib/plausible_web/controllers/auth_controller.ex+++ b/lib/plausible_web/controllers/auth_controller.ex@@ -729,7 +729,7 @@ defmodule PlausibleWeb.AuthController dodefp check_callback_site_permission(site, current_user) doif Plausible.Sites.get_for_user(current_user, site.domain,- roles: [:owner, :admin, :super_admin]+ roles: [:owner, :admin, :editor, :super_admin]) do:okelsediff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exsindex 2f4de856aa..c85cf676fc 100644--- a/test/plausible_web/controllers/auth_controller_test.exs+++ b/test/plausible_web/controllers/auth_controller_test.exs@@ -1386,6 +1386,37 @@ defmodule PlausibleWeb.AuthControllerTest do)end+ test "success callback for search console creates a google auth entry and redirects to integrations form for editor",+ %{conn: conn, user: user} do+ site = new_site()+ add_guest(site, user: user, role: :editor)++ mock_google_access_token(user.email)++ state =+ Phoenix.Token.sign(PlausibleWeb.Endpoint, "google-oauth-state", [+ site.id,+ "search-console"+ ])++ callback_params = %{"code" => "CodeForToken", "state" => state}+ conn = get(conn, Routes.auth_path(conn, :google_auth_callback), callback_params)++ assert redirected_to(conn, 302) ==+ Routes.site_path(conn, :settings_integrations, site.domain)++ assert_matches %{+ access_token: "SomeAccessToken",+ refresh_token: "SomeRefreshToken",+ user_id: ^user.id,+ email: ^user.email,+ expires: %NaiveDateTime{}+ } =+ Repo.one(+ from ga in Plausible.Site.GoogleAuth, where: ga.site_id == ^site.id+ )+ end+test "success callback for search console handles repeat callback for the same site gracefully",%{conn: conn, user: user} dosite = new_site(owner: user)