How to make a function rule for action in controller?

Hi everyone :)

I`m new with yii2.

My question is:

I have a controller, and i want to run a boolean function before some actions, that will tell the system if the user is allowed to access this action (a rule, basically).

What is the rightest way to do that?

Thanks!

Hi!

I would suggest start reading the guide about authentication and authorization:

http://www.yiiframework.com/doc-2.0/guide-security-authorization.html

I’m sure your questions will be answered.

Regards

Thanks!

Is there a way to render a specific view or redirect to another page in case that the rule was failed?

\yii\filters\AccessRule::$denyCallback

Hi,

Yes like phtamas said.

Look at his link - OR at the link I posted…

It is described there.

denyCallback and matchCallback

Regards