A
A
Alexander Sinitsyn2018-10-01 12:27:12
Yii
Alexander Sinitsyn, 2018-10-01 12:27:12

Why isn't it asking for a password?

Added the Admin module
In it I made a login form and AdminController from which all controllers inherited.

spoiler
abstract class AdminController extends Controller
{
    public $layout = 'main';

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::class,
                'rules' => [
                    [
                        'actions' => ['login'],
                        'allow' => true,
                        'roles' => ['?'],
                    ],
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::class,
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }
}

I thought about how ... if they enter the admin panel, then the login page is available for the guest, the rest are only for registered ones.
But for some reason it didn't work. In other controllers, the password is not requested.
What did I misunderstand?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Decadal, 2018-10-01
@Decadal

spoiler
bd4923bfe9.jpg

judging by your comment, this screenshot will be news to you.
You simply overwrite all the keys declared in the parent class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question