Skip to content

Conversation

ktpl-prakash
Copy link
Contributor

@ktpl-prakash ktpl-prakash commented Sep 8, 2018

Description

Fixed Last Logged In date when we authenticate a customer via REST API.

Fixed Issues (if relevant)

#17488: Authenticating a customer via REST API does not update the last logged in data #17488

Manual testing scenarios

  1. Create a new customer account
  2. Login with that customer using the default Magento frontend
  3. View the customer in the Magento admin area, and note that the Last Logged In value has been updated
  4. Request a customer token via this API endpoint: /rest/V1/integration/customer/token

http://{{base_url}}/rest/V1/integration/customer/token/?username=[email protected]&password=examplel@123

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @prakashpatel07. Thank you for your contribution
Here is 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-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@ktpl-prakash ktpl-prakash changed the title Prakashpatel07 develop 2.2 patch 17488 Fix #17488 Authenticating a customer via REST API does not update the last logged in data Sep 8, 2018
@ktpl-prakash ktpl-prakash changed the title Fix #17488 Authenticating a customer via REST API does not update the last logged in data #17488 Fix Authenticating a customer via REST API does not update the last logged in data Sep 8, 2018
__('You did not sign in correctly or your account is temporarily disabled.')
);
}
$this->eventManager->dispatch('customer_login', ['customer' => $customerDataObject]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this event be thrown in case when token used instead of when it is acquired?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paliarush Actually such an event should be thrown once a customer is logged id that is the case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slavvka Just to confirm I was on right track or should I use a @paliarush suggestion or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prakashpatel07 after discussing this, I think current implementation is good. Thanks

Copy link
Member

@slavvka slavvka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the issue

TokenCollectionFactory $tokenModelCollectionFactory,
CredentialsValidator $validatorHelper
CredentialsValidator $validatorHelper,
ManagerInterface $eventManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make in backward compatible way. Please refer to the guide https://devdocs.magento.com/guides/v2.2/contributor-guide/backward-compatible-development/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me use the Backward Сompatibility Policy.

Copy link
Contributor

@0m3r 0m3r Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding Backward compatible development

Adding a constructor parameter

Add a new optional parameter to the constructor at the end of the arguments list instead of modifying the constructor.

In the constructor body, if the new dependency is not provided (i.e. the value of the introduced argument is null), fetch the dependency using Magento\Framework\App\ObjectManager::getInstance().

So

 CredentialsValidator $validatorHelper,
 ManagerInterface $eventManager = null
...
 $this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get(ManagerInterface::class); 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extactly. Thank you @0m3r :)

Copy link
Contributor

@0m3r 0m3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to long line 77 :(

77 | ERROR | Line exceeds maximum limit of 120 characters; contains 129
| | characters

Split on two

$this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance()
    ->get(ManagerInterface::class);

@magento-engcom-team magento-engcom-team added this to the Release: 2.2.8 milestone Oct 5, 2018
@magento-engcom-team
Copy link
Contributor

Hi @slavvka, thank you for the review.
ENGCOM-3102 has been created to process this Pull Request

@magento-engcom-team
Copy link
Contributor

@prakashpatel07 thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository.

magento-engcom-team pushed a commit that referenced this pull request Oct 30, 2018
@magento-engcom-team
Copy link
Contributor

Hi @prakashpatel07. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants