How can I login customer in specific store programmatically in Magento 2?
I've tried to override execute method of
and did something like this:
$this->storeManager->setCurrentStore("store_code"); $store = $this->storeRepository->getActiveStoreByCode("store_code"); $this->httpContext->setValue("store", "store_code", "default"); $this->storeCookieManager->setStoreCookie($store); $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']); $this->session->setCustomerDataAsLoggedIn($customer);
But it didn't work.
I need to do main store, where customer will insert his credentials, and after that customer will logged in and redirected to store according to his customer group