mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix assistants not being able to do user links
This commit is contained in:
parent
79e25bfd6b
commit
9c7bbc127b
3 changed files with 5 additions and 2 deletions
|
@ -151,7 +151,7 @@ defmodule Philomena.UserLinks do
|
||||||
end
|
end
|
||||||
|
|
||||||
def count_user_links(user) do
|
def count_user_links(user) do
|
||||||
if Canada.Can.can?(user, :index, UserLink) do
|
if Canada.Can.can?(user, :index, %UserLink{}) do
|
||||||
UserLink
|
UserLink
|
||||||
|> where([ul], ul.aasm_state in ^["unverified", "link_verified", "contacted"])
|
|> where([ul], ul.aasm_state in ^["unverified", "link_verified", "contacted"])
|
||||||
|> Repo.aggregate(:count, :id)
|
|> Repo.aggregate(:count, :id)
|
||||||
|
|
|
@ -253,6 +253,9 @@ defimpl Canada.Can, for: [Atom, Philomena.Users.User] do
|
||||||
def can?(%User{role: "assistant", role_map: %{"UserLink" => "moderator"}}, :edit, %UserLink{}),
|
def can?(%User{role: "assistant", role_map: %{"UserLink" => "moderator"}}, :edit, %UserLink{}),
|
||||||
do: true
|
do: true
|
||||||
|
|
||||||
|
def can?(%User{role: "assistant", role_map: %{"UserLink" => "moderator"}}, :index, %UserLink{}),
|
||||||
|
do: true
|
||||||
|
|
||||||
# View forums
|
# View forums
|
||||||
def can?(%User{role: "assistant"}, :show, %Forum{access_level: level})
|
def can?(%User{role: "assistant"}, :show, %Forum{access_level: level})
|
||||||
when level in ["normal", "assistant"],
|
when level in ["normal", "assistant"],
|
||||||
|
|
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Admin.UserLinkController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp verify_authorized(conn, _opts) do
|
defp verify_authorized(conn, _opts) do
|
||||||
case Canada.Can.can?(conn.assigns.current_user, :index, UserLink) do
|
case Canada.Can.can?(conn.assigns.current_user, :index, %UserLink{}) do
|
||||||
true -> conn
|
true -> conn
|
||||||
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
|
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue