I am using Magento 2 Instance and while login in to the admin panel I am facing 2FA - Google Auth Not Looking properly. Please check in below Image.
- I would open Network tab in browser and see error response for this QR code image. Maybe you can provide sample admin credentials to see?Roman Kabanov– Roman Kabanov2021-11-11 08:37:36 +00:00Commented Nov 11, 2021 at 8:37
- did you find out the solution , i am also facing the same issueRitesh Kumar– Ritesh Kumar2024-11-25 05:59:27 +00:00Commented Nov 25, 2024 at 5:59
2 Answers
Temporary fix: Disable TwoFactorAuth module using below command:
php bin/magento module:disable Magento_TwoFactorAuth Then execute the below commands.
php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento setup:static-content:deploy -f php bin/magento cache:flush Now you are able to login/use the admin of your Magento 2 store.
- Thats Ok but I want to login with Magento_TwoFactorAuth and QR Code image not showing .SURENDER SINGH– SURENDER SINGH2021-11-11 04:08:11 +00:00Commented Nov 11, 2021 at 4:08
i also faced the same issue , i am writing here just so that it could be helpful to others . I faced the same issue on Magento version 2.4.7 .
open path vendor/magento/module-two-factor-auth/Controller/Adminhtml/Google/Qr.php
change the function
public function execute() { $pngData = $this->google->getQrCodeAsPng($this->getUser()); $this->rawResult ->setHttpResponseCode(200) ->setHeader('Content-Type', 'image/png') ->setContents($pngData); return $this->rawResult; } to
public function execute() { ob_end_clean(); ob_start(); $pngData = $this->google->getQrCodeAsPng($this->getUser()); $this->rawResult ->setHttpResponseCode(200) ->setHeader('Content-Type', 'image/png') ->setContents($pngData); return $this->rawResult; ob_end_clean(); } This solved the issue for me . Please make sure your version have the same code before overwriting , the main thing to note here is , i have ob_end_clean() and ob_start().
