This commit is contained in:
Adam Rutkowski 2024-11-12 14:35:27 +01:00
parent 9322a853fb
commit 4a273045fe

View File

@ -151,17 +151,12 @@ defmodule PlausibleWeb.Site.MembershipController do
|> Enum.map(fn {k, v} -> {v, k} end)
|> Enum.into(%{})
def update_role_by_user(conn, %{"id" => user_id} = params) do
site = conn.assigns.site
membership = Repo.get_by!(Membership, user_id: user_id, site_id: site.id)
params = Map.put(params, "id", membership.id)
update_role(conn, params)
end
defp update_role(conn, %{"id" => id, "new_role" => new_role_str}) do
def update_role_by_user(conn, %{"id" => user_id, "new_role" => new_role_str}) do
%{site: site, current_user: current_user, current_user_role: current_user_role} = conn.assigns
membership = Repo.get!(Membership, id) |> Repo.preload(:user)
membership =
Membership |> Repo.get_by!(user_id: user_id, site_id: site.id) |> Repo.preload(:user)
new_role = Map.fetch!(@role_mappings, new_role_str)
can_grant_role? =