When I log in to the site is not an active user - the input works well. That is, when I entered, I was thrown to

http://site.ru/my 

and writes that you are not activated. But when I enter as activated - it flips to

 http://site.ru/my 

and writes that access is denied, you need to log in. I do a check through

 Yii::$app->user->isGuest 

That is, in the first result it returns 0, and in the second - 1. Why?

  • the method checks whether the user is a guest or not. That is, if he is a guest, true (1) will return to us, if he is authenticated, false (0) will return accordingly. But without information about where, how and why you have it checked it is difficult to say exactly where you got confused. - Blacknife
  • I know what this method does. The bottom line is that when I log in, the database for this user is status=10 , that is, he is not active. This method returns 0 after I login. I do not log out from the system, but I simply change status=13 in the database, that is, I make it active, reload the page and this method returns 1. so I can not understand why? - Diefair
  • in the User model, there is a findIdentity method, where a user with the specified status is searched, changing the status database to '13', change it in the method, and then understand how it works - Blacknife
  • I have this method such public static function findIdentity($id) { return static::findOne($id); } public static function findIdentity($id) { return static::findOne($id); } - Diefair
  • The isGuest method - the guest says or not the guest, and he doesn’t care what you have in the database, 10 or 13, whether the user is logged in or not. And the message - "access denied" means that the user has logged in (isGuest returns 0), but he does not have rights to the action. We look towards access control. - Bookin

0