N
N
nnkrasovok2019-04-17 16:48:27
Yii
nnkrasovok, 2019-04-17 16:48:27

How to check an authorized user?

I check whether the user is authorized, in order to display the buttons in the menu
if (!Yii::$app->user->isGuest)
, I need the authorized user to still have a certain role (role_id field). and accordingly, he issued different buttons in the menu depending on the role. how can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-04-17
@nnkrasovok

Of course, it's better to use rbac and then just using regular methods, everything is more detailed here: https://www.yiiframework.com/doc/guide/2.0/en/secu... But you can do it this way: PS: Sometimes the option "do without RBAC", seems reasonable and simple. But in practice, it’s better to figure it out once and have a bunch of convenient methods in your arsenal, rather than cycling. Proven by time. Video about RBAC in yii: https://www.youtube.com/channel/UC3jTSXXgSvQI2WJ5f... Everything is complicated and confusing there, only at first glance. But a little "dig" - and everything is logical and simple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question