Don't set session if user isn't logged in

This commit is contained in:
Uku Taht 2020-04-13 15:14:16 +03:00
parent 9e0a45629e
commit 1fc7442ad0

View File

@ -17,7 +17,7 @@ defmodule PlausibleWeb.StatsController do
conn
|> assign(:skip_plausible_tracking, !demo)
|> put_session(site.domain <> "_offer_email_report", nil)
|> remove_email_report_banner(site)
|> put_resp_header("x-robots-tag", "noindex")
|> render("stats.html",
site: site,
@ -122,5 +122,13 @@ defmodule PlausibleWeb.StatsController do
user -> Plausible.Sites.is_owner?(user.id, site)
end
end
defp remove_email_report_banner(conn, site) do
if conn.assigns[:current_user] do
put_session(conn, site.domain <> "_offer_email_report", nil)
else
conn
end
end
end