pooria
(Pooria Morovati)
March 1, 2016, 8:31am
1
Hello,
To do as I said in the title, I added the below code to web.php
'as beforeRequest' => [
'class' => 'yii\filters\AccessControl',
'rules' => [
[
'allow' => true,
'actions' => ['login', 'forgot'],
],
[
'allow' => true,
'roles' => ['@'],
],
],
'denyCallback' => function () {
return Yii::$app->response->redirect(['user/login']);
},
],
but the problem is that ALL other actions like Forgot password are redirected to login page, I want to exclude user/forgot route from the login required condition. please help!
Thanks
softark
(Softark)
March 1, 2016, 9:12am
2
[color="#006400 "]/* Moved from "General Discussions" to "Extensions" */[/color]
pooria
(Pooria Morovati)
March 2, 2016, 2:12pm
3
I am really disappointed. have I asked my question badly ?!
softark
(Softark)
March 2, 2016, 10:55pm
4
Try this:
'rules' => [
[
'allow' => true,
'actions' => ['user/login', 'usr/forgot'],
],
pooria
(Pooria Morovati)
March 3, 2016, 6:22pm
5
softark:
Try this:
'rules' => [
[
'allow' => true,
'actions' => ['user/login', 'usr/forgot'],
],
Not working again. In addition, it falls in a redirect loop! I think it does not consider ‘user/login’ and ‘login’ the same!
softark
(Softark)
March 3, 2016, 10:49pm
6
pooria:
I added the below code to web.php
'as beforeRequest' => [
'class' => 'yii\filters\AccessControl',
...
I don’t know if it’s a valid syntax …
May be
'as access' => [
'class' => 'yii\filters\AccessControl',
...
pooria
(Pooria Morovati)
March 4, 2016, 7:37am
7
I think it is valid as is said in stackoverflow.
One strange thing is that ‘user/login’ is not the same as ‘login’ action. which seems weird !
pooria
(Pooria Morovati)
March 5, 2016, 6:59pm
9
softark:
So, is it working now?
Oh sorry I forgot to say! it did not work
pooria
(Pooria Morovati)
April 21, 2016, 1:00pm
10
The problem is solved!!!
The problem was that the real name of the action was not ‘forgot’, It’s ‘request’ action of ‘recovery’ controller. so by adding ‘request’ instead of ‘forgot’, the problem is solved