public function afterLogin()
    {
        $returnUrl = Yii::$app->user->returnUrl;
        $returnUrlParts = explode('/', is_array($returnUrl) ? reset($returnUrl) : $returnUrl);
        $url = end($returnUrlParts) == 'index.php' ? '/' : Yii::$app->user->returnUrl;

        return $this->redirect($url);
    }