We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon ACL error with collections



43.9k

Hi,

  1. what kind of {% content %} should be expected in admin/index.volt ? What happens if you remove it ?
  2. in your volt files, why did you call {% block head %} twice (in layout and in view) ? (this should not have any effect on your problem)


28.4k

Nothing changes if I remove it. The problem is being caused by this part :
{{ this.assets.outputCss('style')}} {{ this.assets.outputJs('js')}} there are no collections with the name style and js because ControllerBase's initialize function was not called. But the admin/index view is being rendered, why is that? The user has no permission to access that area, so he should be redirected to site controller index action and the view should not be even rendered.



43.9k
edited Jun '14

I think "this" is not relevant here. Below is how I call my assets with Volt

{{ assets.outputCss('style')}} 
{{ assets.outputJs('js')}}

You have another problem with your ACL.

What does

$acl->isAllowed($role, $controller, $action)

And

Acl::ALLOW;

return



28.4k

It returns integer 1 or 0. My code doesn't fail in that part. Is is actually done like in this tutorial. https://docs.phalcon.io/en/latest/reference/tutorial-invo.html#log-into-the-application



28.4k
Accepted
answer
edited Jun '14

So the solution was to simply check if the collection exists like so

{% if assets.collection('style').count() %}
    {{ assets.outputCss('style')}}
{% endif %}

Anyway, it's kind of strange that if I redirect a user and I deny him access to a some route, the view is being rendered anyway.