Web.AdminAPI.AdminAPIController: Change right to permission group (except for function names)
This commit is contained in:
parent
1a31d71187
commit
e0b0fde713
@ -40,13 +40,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
|> json(new_user.nickname)
|
|> json(new_user.nickname)
|
||||||
end
|
end
|
||||||
|
|
||||||
def right_add(conn, %{"right" => right, "nickname" => nickname})
|
def right_add(conn, %{"permission_group" => permission_group, "nickname" => nickname})
|
||||||
when right in ["moderator", "admin"] do
|
when permission_group in ["moderator", "admin"] do
|
||||||
user = User.get_by_nickname(nickname)
|
user = User.get_by_nickname(nickname)
|
||||||
|
|
||||||
info =
|
info =
|
||||||
user.info
|
user.info
|
||||||
|> Map.put("is_" <> right, true)
|
|> Map.put("is_" <> permission_group, true)
|
||||||
|
|
||||||
cng = User.info_changeset(user, %{info: info})
|
cng = User.info_changeset(user, %{info: info})
|
||||||
{:ok, user} = User.update_and_set_cache(cng)
|
{:ok, user} = User.update_and_set_cache(cng)
|
||||||
@ -65,17 +65,17 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
def right_add(conn, _) do
|
def right_add(conn, _) do
|
||||||
conn
|
conn
|
||||||
|> put_status(404)
|
|> put_status(404)
|
||||||
|> json(%{error: "No such right"})
|
|> json(%{error: "No such permission_group"})
|
||||||
end
|
end
|
||||||
|
|
||||||
def right_delete(
|
def right_delete(
|
||||||
%{assigns: %{user: %User{:nickname => admin_nickname}}} = conn,
|
%{assigns: %{user: %User{:nickname => admin_nickname}}} = conn,
|
||||||
%{
|
%{
|
||||||
"right" => right,
|
"permission_group" => permission_group,
|
||||||
"nickname" => nickname
|
"nickname" => nickname
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
when right in ["moderator", "admin"] do
|
when permission_group in ["moderator", "admin"] do
|
||||||
if admin_nickname == nickname do
|
if admin_nickname == nickname do
|
||||||
conn
|
conn
|
||||||
|> put_status(403)
|
|> put_status(403)
|
||||||
@ -85,7 +85,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
|
|
||||||
info =
|
info =
|
||||||
user.info
|
user.info
|
||||||
|> Map.put("is_" <> right, false)
|
|> Map.put("is_" <> permission_group, false)
|
||||||
|
|
||||||
cng = User.info_changeset(user, %{info: info})
|
cng = User.info_changeset(user, %{info: info})
|
||||||
{:ok, user} = User.update_and_set_cache(cng)
|
{:ok, user} = User.update_and_set_cache(cng)
|
||||||
@ -98,7 +98,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
def right_delete(conn, _) do
|
def right_delete(conn, _) do
|
||||||
conn
|
conn
|
||||||
|> put_status(404)
|
|> put_status(404)
|
||||||
|> json(%{error: "No such right"})
|
|> json(%{error: "No such permission_group"})
|
||||||
end
|
end
|
||||||
|
|
||||||
def relay_follow(conn, %{"relay_url" => target}) do
|
def relay_follow(conn, %{"relay_url" => target}) do
|
||||||
|
Loading…
Reference in New Issue
Block a user