U4EA
March 3, 2015, 2:43pm
1
Hi folk,
I am creating a site which will force login for any users visiting the site.
I currently have this configured in the site controller (the currently only controller I have), with the follow config…
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'request-password-reset', 'reset-password'],
'allow' => TRUE,
],
[
'actions' => ['logout', 'index'], // add all actions to take guest to login page
'allow' => TRUE,
'roles' => ['@'],
],
],
],
Is there any way I can implement this in Yii\Web\Controller so that every controller/action is blocked for unauthenticated users with the exception of site/login, site/request-password-reset, and site/reset-password?
Thanks in advance.
Pasman
(Pasman P)
March 3, 2015, 4:29pm
2
U4EA:
Hi folk,
I am creating a site which will force login for any users visiting the site.
I currently have this configured in the site controller (the currently only controller I have), with the follow config…
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['login', 'request-password-reset', 'reset-password'],
'allow' => TRUE,
],
[
'actions' => ['logout', 'index'], // add all actions to take guest to login page
'allow' => TRUE,
'roles' => ['@'],
],
],
],
Is there any way I can implement this in Yii\Web\Controller so that every controller/action is blocked for unauthenticated users with the exception of site/login, site/request-password-reset, and site/reset-password?
Thanks in advance.
Your controllers can inherit from defined by you ProtectedController.
In this controller you apply what you need.