I
I
inkkei2019-06-12 19:43:33
Yii
inkkei, 2019-06-12 19:43:33

How to make sure that only one admin (yii2) can enter the admin panel?

There is a small site created using yii2 advanced.
It is necessary to make it so that only one specific user can enter the admin panel (for example, with id = 1), and all users from the database can already enter the user part
PS I know about RBAC, but I need to temporarily do exactly

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2019-06-12
@inkkei

try to do it without RBAC using this mechanism:
https://yiiframework.com.ua/ru/doc/guide/2/securit...

public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => $this->isAdmin(), // это функция которая должна  возвращать true  для юзера с id = 1 , описываете ее в этом же контроллере
                    ],

                ],
            ],
           
        ];
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question