Magento2: First export of coupons fails after installation

Created on 13 May 2016  路  9Comments  路  Source: magento/magento2

Steps to reproduce

  1. Install Magento EE 2.0.5 using composer and run setup.
  2. Go to Admin > Marketing > Cart Price Rules
  3. Create a new rule With Name 'Test' for 'Main Website', Customer Group 'NOT LOGGED IN', Coupon 'Specific Coupon' and 'Use Auto generation' is Yes
  4. Save The Rule
  5. Load The Rule and Got to Manage Coupon Codes
  6. Create 5 Rules with no changes
  7. Export (CSV or Excel XML)

    Expected result

  8. Download of generated file

    Actual result

  9. Redirect to Admin Dashboard

Repeat steps 2, 5 and 7 a second time and the file is downloaded.

Tax Cannot Reproduce Clear Description Format is not valid bug report

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

if ($this->_auth->getAuthStorage()->isFirstPageAfterLogin()) {
    return $this->_redirect($this->_backendUrl->getStartupPageUrl());
}

Reproduced on 2.1.9 with the following steps:

  • logout (if currently logged in)
  • login to admin
  • go to system / export
  • choose advanced pricing
  • hit continue
    => redirect to dashboard
  • go to system / export again
  • choose advanced pricing
  • hit continue
  • the csv file export works as expected

All 9 comments

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.

Preconditions


  1. Fresh Magento 2.2.1 CE or 2.1.9 CE

Steps to reproduce

  1. Add a new subscriber.
  2. Add a new user role, for example "TestRole", with all Role Resources excluding System node.
  3. Create a new user, for example "TestUser", and assign newly created "TestRole" to this user.
  4. Logout.
  5. Login as a new user "TestUser".
  6. Go to Marketing -> Newsletter Subscribers
  7. Press Export button.

Expected result

  1. "Newsletter Subscribers" are successfully exported

Actual result

  1. User is redirected to the Dashboard


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:

  • logout (if currently logged in)
  • login to admin
  • go to system / export
  • choose advanced pricing
  • hit continue
    => redirect to dashboard
  • go to system / export again
  • choose advanced pricing
  • hit continue
  • the csv file export works as expected

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

Was this page helpful?
0 / 5 - 0 ratings