mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +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
|
||||
|
||||
def count_user_links(user) do
|
||||
if Canada.Can.can?(user, :index, UserLink) do
|
||||
if Canada.Can.can?(user, :index, %UserLink{}) do
|
||||
UserLink
|
||||
|> where([ul], ul.aasm_state in ^["unverified", "link_verified", "contacted"])
|
||||
|> 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{}),
|
||||
do: true
|
||||
|
||||
def can?(%User{role: "assistant", role_map: %{"UserLink" => "moderator"}}, :index, %UserLink{}),
|
||||
do: true
|
||||
|
||||
# View forums
|
||||
def can?(%User{role: "assistant"}, :show, %Forum{access_level: level})
|
||||
when level in ["normal", "assistant"],
|
||||
|
|
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Admin.UserLinkController do
|
|||
end
|
||||
|
||||
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
|
||||
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue