Yii2 Dektrium User, make login required for all actions and all controllers

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

[color="#006400"]/* Moved from "General Discussions" to "Extensions" */[/color]

I am really disappointed. have I asked my question badly :( :huh: ?!

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!

I don’t know if it’s a valid syntax …

May be




'as access' => [

	'class' => 'yii\filters\AccessControl',

	...



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 ! ???

So, is it working now?

Oh sorry I forgot to say! it did not work

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 B) :rolleyes: