Show locked message in shared link

pull/1542/head
Uku Taht 5 years ago
parent 383bba947e
commit dc8d20496c

@ -162,22 +162,32 @@ defmodule PlausibleWeb.StatsController do
end end
defp render_shared_link(conn, shared_link) do defp render_shared_link(conn, shared_link) do
conn cond do
|> assign(:skip_plausible_tracking, true) !shared_link.site.locked ->
|> put_resp_header("x-robots-tag", "noindex") conn
|> delete_resp_header("x-frame-options") |> assign(:skip_plausible_tracking, true)
|> render("stats.html", |> put_resp_header("x-robots-tag", "noindex")
site: shared_link.site, |> delete_resp_header("x-frame-options")
has_goals: Plausible.Sites.has_goals?(shared_link.site), |> render("stats.html",
title: "Plausible · " <> shared_link.site.domain, site: shared_link.site,
offer_email_report: false, has_goals: Plausible.Sites.has_goals?(shared_link.site),
demo: false, title: "Plausible · " <> shared_link.site.domain,
skip_plausible_tracking: true, offer_email_report: false,
shared_link_auth: shared_link.slug, demo: false,
embedded: conn.params["embed"] == "true", skip_plausible_tracking: true,
background: conn.params["background"], shared_link_auth: shared_link.slug,
theme: conn.params["theme"] embedded: conn.params["embed"] == "true",
) background: conn.params["background"],
theme: conn.params["theme"]
)
shared_link.site.locked ->
owner = Plausible.Sites.owner_for(shared_link.site)
conn
|> assign(:skip_plausible_tracking, true)
|> render("site_locked.html", owner: owner, site: shared_link.site)
end
end end
defp remove_email_report_banner(conn, site) do defp remove_email_report_banner(conn, site) do

@ -38,9 +38,11 @@
This site is currently locked and cannot be accessed. You can check back later or contact the site owner to unlock it. This site is currently locked and cannot be accessed. You can check back later or contact the site owner to unlock it.
</p> </p>
</div> </div>
<div class="mt-6 w-full text-center"> <%= if @conn.assigns[:current_user] do %>
<%= link("Back to my sites", to: "/sites", class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm") %> <div class="mt-6 w-full text-center">
</div> <%= link("Back to my sites", to: "/sites", class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:text-sm") %>
</div>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

@ -20,12 +20,12 @@
<div class="my-44"> <div class="my-44">
<div class="block pulsating-circle"></div> <div class="block pulsating-circle"></div>
<p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal"> <p class="text-gray-600 dark:text-gray-400 text-xs absolute left-0 bottom-0 mb-6 w-full text-center leading-normal">
Need to see the snippet again? <%= link("Click here", to: "/#{URI.encode_www_form(@site.domain)}/snippet", class: "text-indigo-600 text-underline")%><br /> Need to see the snippet again? <%= link("Click here", to: "/#{URI.encode_www_form(@site.domain)}/snippet", class: "text-indigo-600 dark:text-indigo-500 text-underline")%><br />
Not working? <%= link("Troubleshoot the integration", to: "https://plausible.io/docs/troubleshoot-integration#keep-seeing-a-blinking-green-dot", class: "text-indigo-600 text-underline", rel: "noreferrer") %> with our guide Not working? <%= link("Troubleshoot the integration", to: "https://plausible.io/docs/troubleshoot-integration#keep-seeing-a-blinking-green-dot", class: "text-indigo-600 dark:text-indigo-500 text-underline", rel: "noreferrer") %> with our guide
<%= if Application.get_env(:plausible, :is_selfhost) do %> <%= if Application.get_env(:plausible, :is_selfhost) do %>
first<br /> Still not working? Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 text-underline" ) %> first<br /> Still not working? Ask on our <%= link("community-supported forum", to: "https://github.com/plausible/analytics/discussions", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %>
<% else %> <% else %>
first<br /> Still not working? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-600 text-underline" ) %> and we will help you with your setup first<br /> Still not working? <%= link("Contact us", to: "https://plausible.io/contact", class: "text-indigo-600 dark:text-indigo-500 text-underline" ) %> and we will help you with your setup
<% end %> <% end %>
</p> </p>
</div> </div>

@ -193,6 +193,16 @@ defmodule PlausibleWeb.StatsControllerTest do
conn = get(conn, "/share/test-site.com/?auth=#{link.slug}") conn = get(conn, "/share/test-site.com/?auth=#{link.slug}")
assert Plug.Conn.get_resp_header(conn, "x-frame-options") == [] assert Plug.Conn.get_resp_header(conn, "x-frame-options") == []
end end
test "shows locked page if page is locked", %{conn: conn} do
site = insert(:site, domain: "test-site.com", locked: true)
link = insert(:shared_link, site: site)
conn = get(conn, "/share/test-site.com/?auth=#{link.slug}")
assert html_response(conn, 200) =~ "Site locked"
refute String.contains?(html_response(conn, 200), "Back to my sites")
end
end end
describe "POST /share/:slug/authenticate" do describe "POST /share/:slug/authenticate" do

Loading…
Cancel
Save