mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
force authorization
This commit is contained in:
parent
9f6ac9753d
commit
dc1cacbcc7
1 changed files with 8 additions and 0 deletions
|
@ -8,6 +8,7 @@ defmodule PhilomenaWeb.Admin.ReportController do
|
|||
alias Philomena.Repo
|
||||
import Ecto.Query
|
||||
|
||||
plug :verify_authorized
|
||||
plug :load_and_authorize_resource, model: Report, only: [:show], preload: [:admin, user: [:linked_tags, awards: :badge]]
|
||||
|
||||
def index(conn, %{"rq" => query_string}) do
|
||||
|
@ -80,4 +81,11 @@ defmodule PhilomenaWeb.Admin.ReportController do
|
|||
%{created_at: :desc}
|
||||
]
|
||||
end
|
||||
|
||||
defp verify_authorized(conn, _opts) do
|
||||
case Canada.Can.can?(conn.assigns.current_user, :index, Report) do
|
||||
true -> conn
|
||||
false -> PhilomenaWeb.NotAuthorizedPlug.call(conn)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue