Update User to allow admin search users.
This commit is contained in:
@@ -239,6 +239,17 @@ defmodule DecentralisedBookIndex.Accounts.User do
|
||||
|
||||
filter expr(role == :moderator)
|
||||
end
|
||||
|
||||
read :search do
|
||||
argument :email, :ci_string do
|
||||
constraints allow_empty?: true
|
||||
default ""
|
||||
end
|
||||
|
||||
filter expr(contains(email, ^arg(:email)))
|
||||
|
||||
pagination offset?: true, default_limit: 10
|
||||
end
|
||||
end
|
||||
|
||||
policies do
|
||||
@@ -246,6 +257,10 @@ defmodule DecentralisedBookIndex.Accounts.User do
|
||||
authorize_if always()
|
||||
end
|
||||
|
||||
bypass actor_attribute_equals(:role, :admin) do
|
||||
authorize_if always()
|
||||
end
|
||||
|
||||
policy always() do
|
||||
forbid_if always()
|
||||
end
|
||||
@@ -276,6 +291,7 @@ defmodule DecentralisedBookIndex.Accounts.User do
|
||||
|
||||
code_interface do
|
||||
define :list_moderators
|
||||
define :search, action: :search, args: [:email]
|
||||
|
||||
define :get_by_id, action: :read, get_by: [:id]
|
||||
define :get_by_email, args: [:email]
|
||||
|
||||
Reference in New Issue
Block a user