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

Vokuro privateResources with assets not working

Hi,

This is the privateResources.php

<?php

use Phalcon\Config;
use Phalcon\Logger;

return new Config([
    'privateResources' => [
        'users' => [
            'index',
            'search',
            'edit',
            'create',
            'delete',
            'changePassword'
        ],
        'profiles' => [
            'index',
            'search',
            'edit',
            'create',
            'delete'
        ],
        'permissions' => [
            'index'
        ]
    ]
]);

This is my UsersController.php

 public function indexAction(){

        $this->assets
            ->collection("header")
            ->addCss('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', false)
            ->addCss('https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', false)
            ->addCss('https://fonts.googleapis.com/css?family=Josefin+Sans:400,300', false)
            ->addCss('css/style.css');

        $this->assets
            ->collection("footer")
            ->addJs('js/modernizr.custom.70736.js')
            ->addJs('https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', false)
            ->addJs('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js', false)
            ->addJs('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js', false)
            ->addJs('js/index.js');
    }

index.volt

{{ assets.outputCss("header") }}
</head>
<body>

    {{ content() }}

</body>
{{ assets.outputJs("footer") }}

Working

https://localhost/vokuro/index

After login

https://localhost/vokuro/users

Error

The collection does not exist in the manager
#0 [internal function]: Phalcon\Assets\Manager->get('header')
#1 C:\xampp7013\htdocs\vokuro\cache\volt\c__xampp7013_htdocs_vokuro_app_views_index.volt.php(6): Phalcon\Assets\Manager->outputCss('header')
#2 [internal function]: unknown()
#3 [internal function]: Phalcon\Mvc\View\Engine\Volt->render('C:\\xampp7013\\ht...', Array, true)
#4 [internal function]: Phalcon\Mvc\View->_engineRender(Array, 'index', true, true, NULL)
#5 [internal function]: Phalcon\Mvc\View->render('user_control', 'index', Array)
#6 C:\xampp7013\htdocs\vokuro\public\index.php(41): Phalcon\Mvc\Application->handle()
#7 {main}

When i comment the privateResources.php /users is working, but the ACL not.

Please need help

Rgds Stefan



43.9k

Hi,

try to logout from app and clear cookies.



59.9k

Hi,

i did this several times, but i think that i found the problem, but not the solution.

In ControllerBase.php, It goes always in the else part line 53:

https://github.com/phalcon/vokuro/blob/master/app/controllers/ControllerBase.php

     if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
                $dispatcher->forward([
                    'controller' => $controllerName,
                    'action' => 'index'
                ]);
            } else {
                $dispatcher->forward([
                    'controller' => 'user_control',
                    'action' => 'index'
                ]);
            }
            return false;

So i add the css asigns into the indexAction of the UserControlController.php line 21

https://github.com/phalcon/vokuro/blob/master/app/controllers/UserControlController.php

Now it works half way, the assigns are loaded. My message now is, but i am Administrator:

You don't have access to this module:  users : index

Maybe someone can help me :-/



43.9k
Accepted
answer

Hi,

if you plan to use all your assets bundles application wide, you better build them in initialize method of ControllerBase.php.

I do have to look at deeper in vokuro code to help you regarding the acl problem.

But, I think that vokuro use a file adapter for caching the acl list if there is no apc cache alvailable (I guess so), maybe delete files in vokuro/cache/acl folder ...



59.9k

Hi,

at this moment i also want to comment the same thoughts and we were totally right :-) The data.txt was the problem, so i deleted and it works.

Now i have another question, what else :-)

Think i will open another discussion.

Thx @le51