Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question