2.0.5 using composer and run setup.Export (CSV or Excel XML)
Download of generated file
Redirect to Admin Dashboard
Repeat steps 2, 5 and 7 a second time and the file is downloaded.
Issue also exists in Magento 2.0.6 EE and 2.0.7 EE
I experienced a similar issue on CE 2.1.2 but it's not limited to fresh installations or the price rules section. Actually every download action in admin panel is affected after login.
During login, a is_first_visit session storage flag is set. On subsequent page loads, this flag is never unset until you attempt to download a file. Then the flag is read and unset at the same time. Session::isFirstPageAfterLogin() evaluates to true and a redirect to the startup page (not necessarily dashboard) is triggered. On the next attempt, download succeeds because the flag is now unset and Session::isFirstPageAfterLogin() evaluates to false.
Update: I operate on an admin account with limited permissions. The _Notifications_ permission is not granted and thus the AdminNotification module does not unset the flag.
I can confirm what @mam08ixo is writing. I have Magento_AdminNotification disabled on a Magento 2.1.5 shop and observe the exact same behavior. On first try of download (in my case an order export) I get redirected to the dashboard, on second try it works.
@jmackiol-dotsource, thank you for your report.
We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue.
We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9
I could reproduce this issue, @magento-engcom-team please re-open this issue.
This happens because of the "is_first_visit" flag. Magento does not clean it correctly.
When a user logs in to the admin panel, Magento sets the "is_first_visit" flag using this method \Magento\Backend\Model\Auth\Session->setIsFirstPageAfterLogin() and removes it here \Magento\AdminNotification\Block->canShow() ... $this->_authSession->isFirstPageAfterLogin()
But, if a user does not have Role Resources "System -> Other settings -> Notifications", the \Magento\AdminNotification\Block->canShow() method won't be executed and the "is_first_visit" flag still equals 'true'.
And when user tries to export "Newsletter Subscribers", Magento checks the "is_first_visit" flag here \Magento\Backend\App\Response\Http\FileFactory->create() ... $this->_auth->getAuthStorage()->isFirstPageAfterLogin() and redirects to the dashboard.
This also happens in Magento 2.1.7 CE, it redirects to startup page the first time when user tries to export a file and then subsequent file downloads will succeed.
EDIT Regarding an earlier comment here by @mam08ixo, I am working on a similar situation where Magento_AdminNotification module output is disabled at Store > Configuration > Advanced to hide the notification bell icon from the top menu.
@magento-engcom-team
This should be reopened, happens when exporting advanced price rules as well. The trigger is located here:
vendor/magento/module-backend/App/Response/Http/FileFactory.php:103
if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
return $this->_redirect($this->_backendUrl->getStartupPageUrl());
}
Reproduced on 2.1.9 with the following steps:
Same behavior as @luckyduck on Magento 2.2.3, if user does not have access to Magento Admin Notification user can't download any PDF after login.
@magento-engcom-team
Verified the issue on Magento 2.2.4
Most helpful comment
@magento-engcom-team
This should be reopened, happens when exporting advanced price rules as well. The trigger is located here:
vendor/magento/module-backend/App/Response/Http/FileFactory.php:103
Reproduced on 2.1.9 with the following steps:
=> redirect to dashboard