For some reason, after logging in, the user details gets lost.
I created a Customer class, implemented IdentityInterface and extended ActiveRecord with this class.
When a customer logs in, the customer is properly authenticated. I noticed at this point (using a var_dump) that the Yii::$app->user is properly set to the appropriate Customer instance, and I also noticed the Yii::$app->session is enabled. This is right after the $model->login() function; where $model here is an instance of the de-facto LoginForm below.
public function login()
{
if ($this->validate()) {
return Yii::$app->user->login($this->getCustomer(), $this->rememberMe ? 3600 * 24 * 30 : 0);
} else {
return false;
}
}
However, after the redirect in $this->goBack(), I noticed Yii::$app->user — which was once an instance of yii\web\User, with its identityClass at app/models/Customer — is now null. I also noticed that the session at this point (immediately after the redirect) is null.
This means Yii::$app->user->isGuest is always true even after a customer has been properly authenticated.
How do I carry the logged-in user along through the redirect?