Current user is guest, can not render qr code!

Hi,

I followed this tutorial on having an MFA with login.

Now after following all the steps i have an issue.

Invalid Call – yii\base\InvalidCallException
Current user is guest, can not render qr code!
1. in C:\xampp\htdocs\Schoolproject\vendor\vxm\yii2-mfa\src\QrCodeWidget.phpat line 80
7172737475767778798081828384        if ($this->image) {
            $params['image'] = $this->image;
        }
 
        $uri = $this->user->getQrCodeUri($params);
 
        if ($uri) {
            return Html::img($uri, $this->options);
        } else {
            throw new InvalidCallException('Current user is guest, can not render qr code!');
        }
    }
 
}

On the bottom of the tutorial it says

Notice: when use this widget ensure user had been logged in, if not an yii\base\InvalidCallException will be throw.

But im a bit confused on how to fix this then, because i cant even log in now without fixing this.

Hope its also not outdated

You’re attempting to access a user object which doesn’t exist on whatever context you’re calling it from. If you want the user object you can use:

Yii:$app->user