mirror of
https://github.com/plausible/analytics.git
synced 2025-01-08 11:06:40 +03:00
Clean up
This commit is contained in:
parent
9322a853fb
commit
4a273045fe
@ -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? =
|
||||
|
Loading…
Reference in New Issue
Block a user