Something went wrong.
The below solution allows facilitating login customer programmatically without password in Magento 2.
If you have any doubts regarding this post, just mention them in the Comments section below.
Also, if you are developing a login module using which the customer can log in with just a click or by only entering the Email ID, you may find this solution helpful.
Magento 2 allows customers to log in from the store’s frontend, and the admin can also handle customers from the backend.
Method to Login Customer Programmatically Without Password in Magento 2
But, if you want your customers to log in to the Magento 2 store using only the Email ID?
public function __construct(
$this->session = $session;
$this->customerFactory = $customerFactory;
$customer = $this->customerFactory->create();
$loadCustomer = $customer->loadByEmail($email);
Use the below code in your controller file.
Feel free to share the solution with Magento Community via social media.
You can use this login method if you offer Magento extensions and want to show the demo store where the users can directly log in without having to remember a password.
In the $email variable, enter the email id of the customer you want to log in.
In all these scenarios, offering an easy login where users can have quick access to the store only contributes to a better user experience and thus benefits your business!
Thank you for subscribing.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
I would be happy to help.