A
A
AlexAll2019-04-21 07:01:36
Yii
AlexAll, 2019-04-21 07:01:36

Why doesn't AdminLTE Asset Bundle for yii2 redirect to login.php?

Installed, did everything according to the instructions, compared with other sites that work for me, all one to one, but for some reason on one site when entering the backend
Gives an error
Trying to get property of non-object
on this line in backend/views/layouts /header.php

<span class="hidden-xs"><?= Yii::$app->user->identity->username; ?></span>

In principle, it is clear what the error is, since the user is not authorized and cannot be found.
But why doesn't it redirect to login.php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2019-04-21
@kawabanga

1) Because it's a view. Manipulations with redirects should be done in the controller as much as possible. better in controller access rules.
2) <?= !Yii::$app->user->isGuest? Yii::$app->user->identity->username : ''; ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question