simialbi / yii2-elfinder

This extension integrates the jQuery elFinder into yii2 framework
MIT License
7 stars 5 forks source link

login time expired #13

Open paskuale75 opened 2 years ago

paskuale75 commented 2 years ago

When the time expires and the user is no longer logged in, elfinder continues to do operations as if nothing happened.

simialbi commented 2 years ago

Hi @paskuale75 Yes, that's because the controller has no access behaviors registered by default. If you'd like to change this, I think it's the easiest why you register them via app config.

paskuale75 commented 2 years ago

Hi @paskuale75 Yes, that's because the controller has no access behaviors registered by default. If you'd like to change this, I think it's the easiest why you register them via app config.

Thanks @simialbi register them via app config, have you small example for this ?

simialbi commented 2 years ago

It should work like this (untested):

    'components' => [
        // ...
    ],
    'container' => [
        'definitions' => [
            'simialbi\yii2\elfinder\controllers\ConnectionController' => [
                'as access' => [
                    'class' => 'yii\filters\AccessControl',
                    'rules' => [
                        [
                            'allow' => true,
                            'actions' => ['index'],
                            'roles' => ['@']
                        ]
                    ]
                ]
            ]
        ]
    ]
paskuale75 commented 2 years ago

ok @simialbi I will try as you advised me, two questions: 1) could you add it as an option in the component and the second... 2) where can I learn more about the possibility of managing this container ?

Thanks

simialbi commented 2 years ago
  1. It would be misplaced there. Access control is always done via controllers
  2. here
paskuale75 commented 2 years ago

Thanks @simialbi it works fine, only one thing being a response json does not redirect at login but returns the message 403 forbidden, do you have any advice to redirect the login page when the session expires ?

simialbi commented 2 years ago

It's not this easy. The problem here is, that it's not a regular pjax request from the framework which would redirect if a 301 header is sent. It's an ajax request from elfinder.js itself...

paskuale75 commented 2 years ago

Therefore the only hope is to have this attitude from inside the component ? Thanks

simialbi commented 2 years ago

Would that really change anything? If the mask is already rendered, you'll see the exact same behavior, don't you?