From caeb923664ac920eca65579f29fe237671f0444f Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Fri, 11 Jun 2021 12:07:10 +0300 Subject: [PATCH] Rename AuthorizeStatsPlug -> AuthorizeSiteAccess --- lib/plausible_web/controllers/site/membership_controller.ex | 4 ++-- lib/plausible_web/controllers/site_controller.ex | 2 +- lib/plausible_web/controllers/stats_controller.ex | 2 +- .../{authorize_stats_plug.ex => authorize_site_access.ex} | 2 +- lib/plausible_web/router.ex | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename lib/plausible_web/plugs/{authorize_stats_plug.ex => authorize_site_access.ex} (96%) diff --git a/lib/plausible_web/controllers/site/membership_controller.ex b/lib/plausible_web/controllers/site/membership_controller.ex index e2ecf2dd0e13..3b572a6c3899 100644 --- a/lib/plausible_web/controllers/site/membership_controller.ex +++ b/lib/plausible_web/controllers/site/membership_controller.ex @@ -8,9 +8,9 @@ defmodule PlausibleWeb.Site.MembershipController do @only_owner_is_allowed_to [:transfer_ownership_form, :transfer_ownership] plug PlausibleWeb.RequireAccountPlug - plug PlausibleWeb.AuthorizeStatsPlug, [:owner] when action in @only_owner_is_allowed_to + plug PlausibleWeb.AuthorizeSiteAccess, [:owner] when action in @only_owner_is_allowed_to - plug PlausibleWeb.AuthorizeStatsPlug, + plug PlausibleWeb.AuthorizeSiteAccess, [:owner, :admin] when action not in @only_owner_is_allowed_to def invite_member_form(conn, %{"website" => site_domain}) do diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex index c687e2176eea..043374b8db1f 100644 --- a/lib/plausible_web/controllers/site_controller.ex +++ b/lib/plausible_web/controllers/site_controller.ex @@ -5,7 +5,7 @@ defmodule PlausibleWeb.SiteController do plug PlausibleWeb.RequireAccountPlug - plug PlausibleWeb.AuthorizeStatsPlug, + plug PlausibleWeb.AuthorizeSiteAccess, [:owner, :admin] when action not in [:index, :new, :create_site] def index(conn, params) do diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.ex index 4113fe04bc56..cdd2023f4429 100644 --- a/lib/plausible_web/controllers/stats_controller.ex +++ b/lib/plausible_web/controllers/stats_controller.ex @@ -4,7 +4,7 @@ defmodule PlausibleWeb.StatsController do alias Plausible.Stats.Clickhouse, as: Stats alias Plausible.Stats.Query - plug PlausibleWeb.AuthorizeStatsPlug when action in [:stats, :csv_export] + plug PlausibleWeb.AuthorizeSiteAccess when action in [:stats, :csv_export] def stats(%{assigns: %{site: site}} = conn, _params) do has_pageviews = Stats.has_pageviews?(site) diff --git a/lib/plausible_web/plugs/authorize_stats_plug.ex b/lib/plausible_web/plugs/authorize_site_access.ex similarity index 96% rename from lib/plausible_web/plugs/authorize_stats_plug.ex rename to lib/plausible_web/plugs/authorize_site_access.ex index a80b9af9aacf..754820b91bef 100644 --- a/lib/plausible_web/plugs/authorize_stats_plug.ex +++ b/lib/plausible_web/plugs/authorize_site_access.ex @@ -1,4 +1,4 @@ -defmodule PlausibleWeb.AuthorizeStatsPlug do +defmodule PlausibleWeb.AuthorizeSiteAccess do import Plug.Conn use Plausible.Repo diff --git a/lib/plausible_web/router.ex b/lib/plausible_web/router.ex index c23ec1ee6392..babfaa4da4c8 100644 --- a/lib/plausible_web/router.ex +++ b/lib/plausible_web/router.ex @@ -33,7 +33,7 @@ defmodule PlausibleWeb.Router do plug :accepts, ["json"] plug PlausibleWeb.Firewall plug :fetch_session - plug PlausibleWeb.AuthorizeStatsPlug + plug PlausibleWeb.AuthorizeSiteAccess end pipeline :public_api do