Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix shared link creation with password

Uku Taht264b233ca65a
diff --git a/lib/plausible/sites.ex b/lib/plausible/sites.ex
index 4031388bcf..ffdf8b7f9d 100644
--- a/lib/plausible/sites.ex
+++ b/lib/plausible/sites.ex
@@ -19,14 +19,14 @@ defmodule Plausible.Sites do
|> Repo.transaction()
end
- def create_shared_link(site, name) do
+ def create_shared_link(site, name, password \\ nil) do
changes =
SharedLink.changeset(
%SharedLink{
site_id: site.id,
slug: Nanoid.generate()
},
- %{name: name}
+ %{name: name, password: password}
)
Repo.insert(changes)
diff --git a/lib/plausible_web/controllers/site_controller.ex b/lib/plausible_web/controllers/site_controller.ex
index 20bcd236f6..633967c772 100644
--- a/lib/plausible_web/controllers/site_controller.ex
+++ b/lib/plausible_web/controllers/site_controller.ex
@@ -517,7 +517,7 @@ defmodule PlausibleWeb.SiteController do
def create_shared_link(conn, %{"website" => website, "shared_link" => link}) do
site = Sites.get_for_user!(conn.assigns[:current_user].id, website)
- case Sites.create_shared_link(site, link["name"]) do
+ case Sites.create_shared_link(site, link["name"], link["password"]) do
{:ok, _created} ->
redirect(conn, to: "/#{URI.encode_www_form(site.domain)}/settings/visibility")