fix ownership transfer when is_selfhost=true (#2455)

* fix ownership transfer when is_selfhost=true

* add changelog entry
pull/2471/head
ruslandoga 4 years ago committed by GitHub
parent 994e7d09de
commit 77cca04417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -41,6 +41,7 @@ All notable changes to this project will be documented in this file.
- ARM64 support for docker images plausible/analytics#2103
- Add support for international domain names (IDNs) plausible/analytics#2034
- Allow self-hosters to register an account on first launch
- Fix ownership transfer invitation link in self-hosted deployments
### Fixed
- Plausible script does not prevent default if it's been prevented by an external script [plausible/analytics#1941](https://github.com/plausible/analytics/issues/1941)

@ -68,7 +68,9 @@ defmodule PlausibleWeb.InvitationController do
end
defp maybe_end_trial_of_new_owner(multi, new_owner) do
if !Application.get_env(:plausible, :is_selfhost) do
if Application.get_env(:plausible, :is_selfhost) do
multi
else
end_trial_of_new_owner(multi, new_owner)
end
end

@ -161,6 +161,33 @@ defmodule PlausibleWeb.Site.InvitationControllerTest do
assert new_owner_membership.role == :owner
end
test "works in self-hosted", %{conn: conn, user: user} do
patch_env(:is_selfhost, true)
old_owner = insert(:user)
site = insert(:site, members: [old_owner])
invitation =
insert(:invitation,
site_id: site.id,
inviter: old_owner,
email: user.email,
role: :owner
)
post(conn, "/sites/invitations/#{invitation.invitation_id}/accept")
old_owner_membership =
Repo.get_by(Plausible.Site.Membership, user_id: old_owner.id, site_id: site.id)
assert old_owner_membership.role == :admin
new_owner_membership =
Repo.get_by(Plausible.Site.Membership, user_id: user.id, site_id: site.id)
assert new_owner_membership.role == :owner
end
end
describe "POST /sites/invitations/:invitation_id/reject" do

Loading…
Cancel
Save