Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon ACL error with collections



25.3k

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)


15.9k

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.



25.3k
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



15.9k

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



15.9k
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.