I'm trying to make a login of a user externally in PHP.
Need to know which class should be used in Magento 2 to validate by Email & password and once validated, open the session.
I'm dealing with CustomerRepository
Class, where there is a function that's supposed fetch a Customer by Email and returns a CustomerModel
Object but no success. The idea is to get the Model from such user and in case the Model has data, get the password and compare.
$this->answer = $this->customer_Repository->get("pepe1@pepe.com");
When I print in console the answer, it's empty.
I do not find anything related to this topic. Is There any Class that makes this operation directly?
Best Answer
I believe
Magento\Customer\Api\AccountManagementInterface::authenticate()
method call will help you to validate email as well as password. You may also want to check implementation of theMagento\Customer\Controller\Account\LoginPost::execute()
method and how session is prepared in case of success authentication.