magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Fix issue when login is not recorded for updated admin user

Open tkotosz opened this issue 3 years ago • 1 comments

Description (*)

When an admin user is updated through the Magento admin then the reload_acl_flag is set to 1. Because of this during the next login of this admin user the login is not recorded in the logdate and lognum fields of the admin_user table.

This is because these fields are updated with a direct database update after login, but the change is not set on the user model as well. Therefore if any code further down the line saves the user model (which does happen if the acl refreshed) then the values for these field will be reverted to the previous values.

To avoid this problem this PR updates the recordLogin method to set the values on the model as well to preserve the correct values.

Fixed Issues (if relevant)

I did not find this reported in a github issue yet.

Manual testing scenarios (*)

  1. Make sure you have 2 working admin users: admin user A and admin user B
  2. Log in with admin user A to the Magento admin
  3. Navigate to the admin user edit page (System > Permissions > All Users)
  4. Edit admin user B
  5. You don't have to change anything, you can just provide your own password and save admin user B as it is
  6. Saving admin user B without changing anything at all still causes the reload_acl_flag field to switch to 1 in the admin_user table for admin user B
  7. Logout from the admin
  8. Login with admin user B

Expected result: Login is successful and the logdate for admin user B in the admin_user table is the current date.

Actual result (without the fix from this PR): Login is successful but the logdate for admin user B in the admin_user table did NOT change.

Contribution checklist (*)

  • [x] Pull request has a meaningful description of its purpose
  • [x] All commits are accompanied by meaningful commit messages
  • [ ] All new or changed code is covered with unit/integration tests (if applicable)
  • [ ] README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • [ ] All automated tests passed successfully (all builds are green)

tkotosz avatar Aug 12 '22 12:08 tkotosz

Hi @tkotosz. Thank you for your contribution Here are some useful tips how you can test your changes using Magento test environment. Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

:exclamation: Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s) For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

:information_source: Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

:warning: According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar Aug 12 '22 12:08 m2-assistant[bot]

signed CLA, could you please rerun the check?

tkotosz avatar Aug 17 '22 15:08 tkotosz

@tkotosz: you need to close the PR, wait a couple of seconds and then open it again (kind of annoying, but you'll only need to do this for your first PR here)

hostep avatar Aug 25 '22 20:08 hostep

@magento create issue

engcom-Delta avatar Dec 20 '22 08:12 engcom-Delta