M
M
Messi2018-04-04 08:40:59
Yii
Messi, 2018-04-04 08:40:59

How to add code validation correctly?

Hello! Please tell me the logic or steps how to do it right.
There is a label in the database (is_allowed). When any user (not authorized / authorized) enters the site and this label is false, then instead of the login page (or any other page), a page was shown, for example "Forbidden".
How to do it? Do I need to write Access => rules in each controller? Or can it be done in one place?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2018-04-04
@Mx21

Access rules would solve this problem, but there access to certain controllers is by role, not by parameter. In each controller, it is not necessary to write this behavior. It is enough to register in one controller, and then inherit it.

M
Maxim Timofeev, 2018-04-04
@webinar

This must be implemented through RBAC, you create a rule in it and return it depending on is_allowed or true or false, in fact is_allowed itself. Then it is possible to use access filter without any problems, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question