mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 17:44:43 +03:00
Remove google auth from a site
This commit is contained in:
parent
9a91c6d901
commit
0e17a4ecfd
@ -128,6 +128,18 @@ defmodule PlausibleWeb.SiteController do
|
||||
|> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings#google-auth")
|
||||
end
|
||||
|
||||
def delete_google_auth(conn, %{"website" => website}) do
|
||||
site =
|
||||
Sites.get_for_user!(conn.assigns[:current_user].id, website)
|
||||
|> Repo.preload(:google_auth)
|
||||
|
||||
Repo.delete!(site.google_auth)
|
||||
|
||||
conn
|
||||
|> put_flash(:success, "Google account unlinked succesfully")
|
||||
|> redirect(to: "/#{URI.encode_www_form(site.domain)}/settings#google-auth")
|
||||
end
|
||||
|
||||
def update_settings(conn, %{"website" => website, "site" => site_params}) do
|
||||
site = Sites.get_for_user!(conn.assigns[:current_user].id, website)
|
||||
changeset = site |> Plausible.Site.changeset(site_params)
|
||||
|
@ -151,6 +151,7 @@ defmodule PlausibleWeb.Router do
|
||||
delete "/:website/goals/:id", SiteController, :delete_goal
|
||||
put "/:website/settings", SiteController, :update_settings
|
||||
put "/:website/settings/google", SiteController, :update_google_auth
|
||||
delete "/:website/settings/google", SiteController, :delete_google_auth
|
||||
delete "/:website", SiteController, :delete_site
|
||||
|
||||
get "/share/:slug", StatsController, :shared_link
|
||||
|
@ -104,7 +104,9 @@
|
||||
|
||||
<%= if @site.google_auth do %>
|
||||
<div class="py-2"></div>
|
||||
<span class="text-gray-700">Connected Google account: <b><%= @site.google_auth.email %></b></span>
|
||||
<span class="text-gray-700">Linked Google account: <b><%= @site.google_auth.email %></b></span>
|
||||
|
||||
<%= link("Unlink Google account", to: "/#{URI.encode_www_form(@site.domain)}/settings/google", class: "inline-block mt-4 px-4 py-2 border border-gray-300 text-sm leading-5 font-medium rounded-md text-red-700 bg-white hover:text-red-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:text-red-800 active:bg-gray-50 transition ease-in-out duration-150", method: "delete") %>
|
||||
|
||||
<%= if @site.google_auth.property && !(@site.google_auth.property in @search_console_domains) do %>
|
||||
<p class="text-gray-700 mt-6 font-bold">
|
||||
@ -112,7 +114,7 @@
|
||||
</p>
|
||||
<% else %>
|
||||
<p class="text-gray-700 mt-6">
|
||||
Select the Google Search Console property you would like to pull keyword data from. If you don't see your domain, <%= link("set it up and verify", to: "https://docs.#{base_domain()}/google-search-console-integration#1-add-your-site-on-the-search-console", class: "text-indigo-500") %> on Search Console first.
|
||||
Select the Google Search Console property you would like to pull keyword data from. If you don't see your domain, <%= link("set it up and verify", to: "https://docs.#{base_domain()}/google-search-console-integration", class: "text-indigo-500") %> on Search Console first.
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
@ -147,6 +147,29 @@ defmodule PlausibleWeb.SiteControllerTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT /:website/settings/google" do
|
||||
setup [:create_user, :log_in, :create_site]
|
||||
|
||||
test "updates google auth property", %{conn: conn, user: user, site: site} do
|
||||
insert(:google_auth, user: user, site: site)
|
||||
put(conn, "/#{site.domain}/settings/google", %{"google_auth" => %{"property" => "some-new-property.com"}})
|
||||
|
||||
updated_auth = Repo.one(Plausible.Site.GoogleAuth)
|
||||
assert updated_auth.property == "some-new-property.com"
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /:website/settings/google" do
|
||||
setup [:create_user, :log_in, :create_site]
|
||||
|
||||
test "deletes associated google auth", %{conn: conn, user: user, site: site} do
|
||||
insert(:google_auth, user: user, site: site)
|
||||
delete(conn, "/#{site.domain}/settings/google")
|
||||
|
||||
refute Repo.exists?(Plausible.Site.GoogleAuth)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /:website/goals/new" do
|
||||
setup [:create_user, :log_in, :create_site]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user