Generating liveview - no users shown

After using ash-hq installer I continued with:
mix ash_phoenix.gen.live --domain MyApp.Accounts --resource MyApp.Accounts.User --resource-plural users
mix ash_phoenix.gen.live --domain MyApp.Accounts --resource MyApp.Accounts.User --resource-plural users
But /users doesn't list the users (there is one - my own). Console says
[debug] MyApp.Accounts.User.read: skipped query run due to filter being false"
[debug] MyApp.Accounts.User.read: skipped query run due to filter being false"
The user ressource has
actions do
defaults [:read]
actions do
defaults [:read]
6 Replies
ZachDaniel
ZachDaniel4mo ago
Policies are filtering the list What read action is it using?
Nefcairon
NefcaironOP4mo ago
isn't that defined via
defaults [:read]
defaults [:read]
These are the policies:
policies do
bypass AshAuthentication.Checks.AshAuthenticationInteraction do
authorize_if always()
end

policy always() do
forbid_if always()
end
end
policies do
bypass AshAuthentication.Checks.AshAuthenticationInteraction do
authorize_if always()
end

policy always() do
forbid_if always()
end
end
ZachDaniel
ZachDaniel4mo ago
So that forbids all reads that aren't done by AshAuthentication
Nefcairon
NefcaironOP4mo ago
I thought I can completely remove this block to get all users. It works with
policies do
policy always() do
authorize_if always()
end
end
policies do
policy always() do
authorize_if always()
end
end
Shouldn't it also work without a policies-block?
ZachDaniel
ZachDaniel4mo ago
Make sure to read through the policies guide With the policy authorizer: - all policies that apply must pass - at least one policy must apply
Nefcairon
NefcaironOP4mo ago
ah, the line
authorizers: [Ash.Policy.Authorizer]
authorizers: [Ash.Policy.Authorizer]
triggers that. that's why there is in the docs:
Additionally, keep in mind that adding Ash.Policy.Authorizer will require that all actions pass policies. If you want to just add field policies, you will need to add a policy that allows all access explicitly, i.e
Additionally, keep in mind that adding Ash.Policy.Authorizer will require that all actions pass policies. If you want to just add field policies, you will need to add a policy that allows all access explicitly, i.e
Thanks Zach.

Did you find this page helpful?