/** * Login Customer * @return false || \Magento\Customer\Model\Customer */ public function authenticateCustomer() { $customer = $this->getCustomer(); if (!$customer->getId()) { throw new \Exception(__("Customer are no longer exist."), 1); } if ($this->_customerSession->loginById($customer->getId())) { $this->_customerSession->regenerateId(); $this->_customerSession->setLoggedAsCustomerAdmindId($this->getAdminId()); } $this->setUsed(1)->save(); return $customer; }