Magento 2 checkout login with mobile number or email The 2019 Stack Overflow Developer Survey Results Are InIs that possible to set phone number in checkout page?Magento 2 How to Remove the Checkout Login Popup?Client side mobile validation in magento2How can i add a field mobile number at the time of customer registration form in magento 2?restrict customer by phone number (my custom attribute ) with model pluginHow to add unique mobile number function in Magento 2 registration form?Magento 2 customer login from externalMagento 2 add mobile number to checkoutwant to login customer via phone number in magento 2.2display mobile number in create an account page in magento 2

How to quickly solve partial fractions equation?

What do I do when my TA workload is more than expected?

RequirePermission not working

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

What force causes entropy to increase?

Finding the area between two curves with Integrate

How to charge AirPods to keep battery healthy?

How did passengers keep warm on sail ships?

Can we generate random numbers using irrational numbers like π and e?

What is this sharp, curved notch on my knife for?

Can an undergraduate be advised by a professor who is very far away?

What is this business jet?

Alternative to の

Loose spokes after only a few rides

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

How can I define good in a religion that claims no moral authority?

Can there be female White Walkers?

How to type a long/em dash `—`

Dropping list elements from nested list after evaluation

The phrase "to the numbers born"?

Button changing its text & action. Good or terrible?

Is an up-to-date browser secure on an out-of-date OS?

Are spiders unable to hurt humans, especially very small spiders?

Output the Arecibo Message



Magento 2 checkout login with mobile number or email



The 2019 Stack Overflow Developer Survey Results Are InIs that possible to set phone number in checkout page?Magento 2 How to Remove the Checkout Login Popup?Client side mobile validation in magento2How can i add a field mobile number at the time of customer registration form in magento 2?restrict customer by phone number (my custom attribute ) with model pluginHow to add unique mobile number function in Magento 2 registration form?Magento 2 customer login from externalMagento 2 add mobile number to checkoutwant to login customer via phone number in magento 2.2display mobile number in create an account page in magento 2



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to allow the customer to Log in using email or mobile number on the checkout page and the login page.



Note: Mobile number is customer eav attribute.










share|improve this question






























    0















    I want to allow the customer to Log in using email or mobile number on the checkout page and the login page.



    Note: Mobile number is customer eav attribute.










    share|improve this question


























      0












      0








      0








      I want to allow the customer to Log in using email or mobile number on the checkout page and the login page.



      Note: Mobile number is customer eav attribute.










      share|improve this question
















      I want to allow the customer to Log in using email or mobile number on the checkout page and the login page.



      Note: Mobile number is customer eav attribute.







      magento2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 min ago







      Charvi Parikh

















      asked 17 mins ago









      Charvi ParikhCharvi Parikh

      592615




      592615




















          1 Answer
          1






          active

          oldest

          votes


















          0














          For Login with the customer, First you need to make mobile number required field in customer Registration form. Whenever customer register, At that time you need to add a field like mobile no. and save that field to Customer registration page.



          Now when customer login at that time they enter email id or mobile number. For this you need to override this controller



          MagentoCustomerControllerAccountLoginPost


          in your module and add code like below, Path should be like: app/code/Vendor/Modulename/Controller/Account/LoginPost.



          Now keep below code in your controller,



          <?php
          namespace VendorModulenameControllerAccount;

          use MagentoCustomerModelUrl as CustomerUrl;
          use MagentoFrameworkDataFormFormKeyValidator;
          use MagentoCustomerModelAccountRedirect as AccountRedirect;

          class LoginPost extends MagentoCustomerControllerAccountLoginPost

          public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCustomerModelSession $customerSession,
          MagentoCustomerApiAccountManagementInterface $customerAccountManagement,
          CustomerUrl $customerHelperData,
          Validator $formKeyValidator,
          AccountRedirect $accountRedirect,
          MagentoCustomerModelResourceModelCustomerCollectionFactory $customerFactory
          )
          $this->_customerFactory = $customerFactory;
          parent::__construct($context,$customerSession,$customerAccountManagement,$customerHelperData,$formKeyValidator,$accountRedirect);


          public function execute()
          !$this->formKeyValidator->validate($this->getRequest()))
          /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('*/*/');
          return $resultRedirect;

          if ($this->getRequest()->isPost())
          $login = $this->getRequest()->getPost('login');

          if(!strpos($login['username'], '@') !== false )
          $isMobile = $login['username'];
          /* Get email id based on mobile number and login*/
          $customereCollection = $this->_customerFactory->create();
          $customereCollection->addFieldToFilter("mobile", $login['username']);
          foreach($customereCollection as $customerdata)
          $login['username'] = $customerdata['email'];




          if (!empty($login['username']) && !empty($login['password']))
          try
          $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
          $this->session->setCustomerDataAsLoggedIn($customer);
          $this->session->regenerateId();
          if ($this->getCookieManager()->getCookie('mage-cache-sessid'))
          $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
          $metadata->setPath('/');
          $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

          $redirectUrl = $this->accountRedirect->getRedirectCookie();

          if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl)

          $this->accountRedirect->clearRedirectCookie();
          $resultRedirect = $this->resultRedirectFactory->create();
          // URL is checked to be internal in $this->_redirect->success()
          $resultRedirect->setUrl($this->_redirect->success($redirectUrl));
          return $resultRedirect;
          else
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('');
          return $resultRedirect;

          catch (EmailNotConfirmedException $e)
          $value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
          $message = __(
          'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
          $value
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (UserLockedException $e)
          $message = __(
          'You did not sign in correctly or your account is temporarily disabled.'
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (AuthenticationException $e)
          $message = __('You did not sign in correctly or your account is temporarily disabled.');
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (LocalizedException $e)
          $message = $e->getMessage();
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (Exception $e)
          // PA DSS violation: throwing or logging an exception here can disclose customer password
          $this->messageManager->addError(
          __('An unspecified error occurred. Please contact us for assistance.')
          );

          else
          $this->messageManager->addError(__('A login and a password are required.'));



          return $this->accountRedirect->getRedirect();




          I hope this will help






          share|improve this answer

























          • on checkout page, how can i change input type email to text ? so user can add their mobile number.

            – Charvi Parikh
            7 mins ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269815%2fmagento-2-checkout-login-with-mobile-number-or-email%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          For Login with the customer, First you need to make mobile number required field in customer Registration form. Whenever customer register, At that time you need to add a field like mobile no. and save that field to Customer registration page.



          Now when customer login at that time they enter email id or mobile number. For this you need to override this controller



          MagentoCustomerControllerAccountLoginPost


          in your module and add code like below, Path should be like: app/code/Vendor/Modulename/Controller/Account/LoginPost.



          Now keep below code in your controller,



          <?php
          namespace VendorModulenameControllerAccount;

          use MagentoCustomerModelUrl as CustomerUrl;
          use MagentoFrameworkDataFormFormKeyValidator;
          use MagentoCustomerModelAccountRedirect as AccountRedirect;

          class LoginPost extends MagentoCustomerControllerAccountLoginPost

          public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCustomerModelSession $customerSession,
          MagentoCustomerApiAccountManagementInterface $customerAccountManagement,
          CustomerUrl $customerHelperData,
          Validator $formKeyValidator,
          AccountRedirect $accountRedirect,
          MagentoCustomerModelResourceModelCustomerCollectionFactory $customerFactory
          )
          $this->_customerFactory = $customerFactory;
          parent::__construct($context,$customerSession,$customerAccountManagement,$customerHelperData,$formKeyValidator,$accountRedirect);


          public function execute()
          !$this->formKeyValidator->validate($this->getRequest()))
          /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('*/*/');
          return $resultRedirect;

          if ($this->getRequest()->isPost())
          $login = $this->getRequest()->getPost('login');

          if(!strpos($login['username'], '@') !== false )
          $isMobile = $login['username'];
          /* Get email id based on mobile number and login*/
          $customereCollection = $this->_customerFactory->create();
          $customereCollection->addFieldToFilter("mobile", $login['username']);
          foreach($customereCollection as $customerdata)
          $login['username'] = $customerdata['email'];




          if (!empty($login['username']) && !empty($login['password']))
          try
          $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
          $this->session->setCustomerDataAsLoggedIn($customer);
          $this->session->regenerateId();
          if ($this->getCookieManager()->getCookie('mage-cache-sessid'))
          $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
          $metadata->setPath('/');
          $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

          $redirectUrl = $this->accountRedirect->getRedirectCookie();

          if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl)

          $this->accountRedirect->clearRedirectCookie();
          $resultRedirect = $this->resultRedirectFactory->create();
          // URL is checked to be internal in $this->_redirect->success()
          $resultRedirect->setUrl($this->_redirect->success($redirectUrl));
          return $resultRedirect;
          else
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('');
          return $resultRedirect;

          catch (EmailNotConfirmedException $e)
          $value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
          $message = __(
          'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
          $value
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (UserLockedException $e)
          $message = __(
          'You did not sign in correctly or your account is temporarily disabled.'
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (AuthenticationException $e)
          $message = __('You did not sign in correctly or your account is temporarily disabled.');
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (LocalizedException $e)
          $message = $e->getMessage();
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (Exception $e)
          // PA DSS violation: throwing or logging an exception here can disclose customer password
          $this->messageManager->addError(
          __('An unspecified error occurred. Please contact us for assistance.')
          );

          else
          $this->messageManager->addError(__('A login and a password are required.'));



          return $this->accountRedirect->getRedirect();




          I hope this will help






          share|improve this answer

























          • on checkout page, how can i change input type email to text ? so user can add their mobile number.

            – Charvi Parikh
            7 mins ago















          0














          For Login with the customer, First you need to make mobile number required field in customer Registration form. Whenever customer register, At that time you need to add a field like mobile no. and save that field to Customer registration page.



          Now when customer login at that time they enter email id or mobile number. For this you need to override this controller



          MagentoCustomerControllerAccountLoginPost


          in your module and add code like below, Path should be like: app/code/Vendor/Modulename/Controller/Account/LoginPost.



          Now keep below code in your controller,



          <?php
          namespace VendorModulenameControllerAccount;

          use MagentoCustomerModelUrl as CustomerUrl;
          use MagentoFrameworkDataFormFormKeyValidator;
          use MagentoCustomerModelAccountRedirect as AccountRedirect;

          class LoginPost extends MagentoCustomerControllerAccountLoginPost

          public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCustomerModelSession $customerSession,
          MagentoCustomerApiAccountManagementInterface $customerAccountManagement,
          CustomerUrl $customerHelperData,
          Validator $formKeyValidator,
          AccountRedirect $accountRedirect,
          MagentoCustomerModelResourceModelCustomerCollectionFactory $customerFactory
          )
          $this->_customerFactory = $customerFactory;
          parent::__construct($context,$customerSession,$customerAccountManagement,$customerHelperData,$formKeyValidator,$accountRedirect);


          public function execute()
          !$this->formKeyValidator->validate($this->getRequest()))
          /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('*/*/');
          return $resultRedirect;

          if ($this->getRequest()->isPost())
          $login = $this->getRequest()->getPost('login');

          if(!strpos($login['username'], '@') !== false )
          $isMobile = $login['username'];
          /* Get email id based on mobile number and login*/
          $customereCollection = $this->_customerFactory->create();
          $customereCollection->addFieldToFilter("mobile", $login['username']);
          foreach($customereCollection as $customerdata)
          $login['username'] = $customerdata['email'];




          if (!empty($login['username']) && !empty($login['password']))
          try
          $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
          $this->session->setCustomerDataAsLoggedIn($customer);
          $this->session->regenerateId();
          if ($this->getCookieManager()->getCookie('mage-cache-sessid'))
          $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
          $metadata->setPath('/');
          $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

          $redirectUrl = $this->accountRedirect->getRedirectCookie();

          if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl)

          $this->accountRedirect->clearRedirectCookie();
          $resultRedirect = $this->resultRedirectFactory->create();
          // URL is checked to be internal in $this->_redirect->success()
          $resultRedirect->setUrl($this->_redirect->success($redirectUrl));
          return $resultRedirect;
          else
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('');
          return $resultRedirect;

          catch (EmailNotConfirmedException $e)
          $value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
          $message = __(
          'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
          $value
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (UserLockedException $e)
          $message = __(
          'You did not sign in correctly or your account is temporarily disabled.'
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (AuthenticationException $e)
          $message = __('You did not sign in correctly or your account is temporarily disabled.');
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (LocalizedException $e)
          $message = $e->getMessage();
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (Exception $e)
          // PA DSS violation: throwing or logging an exception here can disclose customer password
          $this->messageManager->addError(
          __('An unspecified error occurred. Please contact us for assistance.')
          );

          else
          $this->messageManager->addError(__('A login and a password are required.'));



          return $this->accountRedirect->getRedirect();




          I hope this will help






          share|improve this answer

























          • on checkout page, how can i change input type email to text ? so user can add their mobile number.

            – Charvi Parikh
            7 mins ago













          0












          0








          0







          For Login with the customer, First you need to make mobile number required field in customer Registration form. Whenever customer register, At that time you need to add a field like mobile no. and save that field to Customer registration page.



          Now when customer login at that time they enter email id or mobile number. For this you need to override this controller



          MagentoCustomerControllerAccountLoginPost


          in your module and add code like below, Path should be like: app/code/Vendor/Modulename/Controller/Account/LoginPost.



          Now keep below code in your controller,



          <?php
          namespace VendorModulenameControllerAccount;

          use MagentoCustomerModelUrl as CustomerUrl;
          use MagentoFrameworkDataFormFormKeyValidator;
          use MagentoCustomerModelAccountRedirect as AccountRedirect;

          class LoginPost extends MagentoCustomerControllerAccountLoginPost

          public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCustomerModelSession $customerSession,
          MagentoCustomerApiAccountManagementInterface $customerAccountManagement,
          CustomerUrl $customerHelperData,
          Validator $formKeyValidator,
          AccountRedirect $accountRedirect,
          MagentoCustomerModelResourceModelCustomerCollectionFactory $customerFactory
          )
          $this->_customerFactory = $customerFactory;
          parent::__construct($context,$customerSession,$customerAccountManagement,$customerHelperData,$formKeyValidator,$accountRedirect);


          public function execute()
          !$this->formKeyValidator->validate($this->getRequest()))
          /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('*/*/');
          return $resultRedirect;

          if ($this->getRequest()->isPost())
          $login = $this->getRequest()->getPost('login');

          if(!strpos($login['username'], '@') !== false )
          $isMobile = $login['username'];
          /* Get email id based on mobile number and login*/
          $customereCollection = $this->_customerFactory->create();
          $customereCollection->addFieldToFilter("mobile", $login['username']);
          foreach($customereCollection as $customerdata)
          $login['username'] = $customerdata['email'];




          if (!empty($login['username']) && !empty($login['password']))
          try
          $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
          $this->session->setCustomerDataAsLoggedIn($customer);
          $this->session->regenerateId();
          if ($this->getCookieManager()->getCookie('mage-cache-sessid'))
          $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
          $metadata->setPath('/');
          $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

          $redirectUrl = $this->accountRedirect->getRedirectCookie();

          if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl)

          $this->accountRedirect->clearRedirectCookie();
          $resultRedirect = $this->resultRedirectFactory->create();
          // URL is checked to be internal in $this->_redirect->success()
          $resultRedirect->setUrl($this->_redirect->success($redirectUrl));
          return $resultRedirect;
          else
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('');
          return $resultRedirect;

          catch (EmailNotConfirmedException $e)
          $value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
          $message = __(
          'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
          $value
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (UserLockedException $e)
          $message = __(
          'You did not sign in correctly or your account is temporarily disabled.'
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (AuthenticationException $e)
          $message = __('You did not sign in correctly or your account is temporarily disabled.');
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (LocalizedException $e)
          $message = $e->getMessage();
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (Exception $e)
          // PA DSS violation: throwing or logging an exception here can disclose customer password
          $this->messageManager->addError(
          __('An unspecified error occurred. Please contact us for assistance.')
          );

          else
          $this->messageManager->addError(__('A login and a password are required.'));



          return $this->accountRedirect->getRedirect();




          I hope this will help






          share|improve this answer















          For Login with the customer, First you need to make mobile number required field in customer Registration form. Whenever customer register, At that time you need to add a field like mobile no. and save that field to Customer registration page.



          Now when customer login at that time they enter email id or mobile number. For this you need to override this controller



          MagentoCustomerControllerAccountLoginPost


          in your module and add code like below, Path should be like: app/code/Vendor/Modulename/Controller/Account/LoginPost.



          Now keep below code in your controller,



          <?php
          namespace VendorModulenameControllerAccount;

          use MagentoCustomerModelUrl as CustomerUrl;
          use MagentoFrameworkDataFormFormKeyValidator;
          use MagentoCustomerModelAccountRedirect as AccountRedirect;

          class LoginPost extends MagentoCustomerControllerAccountLoginPost

          public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCustomerModelSession $customerSession,
          MagentoCustomerApiAccountManagementInterface $customerAccountManagement,
          CustomerUrl $customerHelperData,
          Validator $formKeyValidator,
          AccountRedirect $accountRedirect,
          MagentoCustomerModelResourceModelCustomerCollectionFactory $customerFactory
          )
          $this->_customerFactory = $customerFactory;
          parent::__construct($context,$customerSession,$customerAccountManagement,$customerHelperData,$formKeyValidator,$accountRedirect);


          public function execute()
          !$this->formKeyValidator->validate($this->getRequest()))
          /** @var MagentoFrameworkControllerResultRedirect $resultRedirect */
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('*/*/');
          return $resultRedirect;

          if ($this->getRequest()->isPost())
          $login = $this->getRequest()->getPost('login');

          if(!strpos($login['username'], '@') !== false )
          $isMobile = $login['username'];
          /* Get email id based on mobile number and login*/
          $customereCollection = $this->_customerFactory->create();
          $customereCollection->addFieldToFilter("mobile", $login['username']);
          foreach($customereCollection as $customerdata)
          $login['username'] = $customerdata['email'];




          if (!empty($login['username']) && !empty($login['password']))
          try
          $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']);
          $this->session->setCustomerDataAsLoggedIn($customer);
          $this->session->regenerateId();
          if ($this->getCookieManager()->getCookie('mage-cache-sessid'))
          $metadata = $this->getCookieMetadataFactory()->createCookieMetadata();
          $metadata->setPath('/');
          $this->getCookieManager()->deleteCookie('mage-cache-sessid', $metadata);

          $redirectUrl = $this->accountRedirect->getRedirectCookie();

          if (!$this->getScopeConfig()->getValue('customer/startup/redirect_dashboard') && $redirectUrl)

          $this->accountRedirect->clearRedirectCookie();
          $resultRedirect = $this->resultRedirectFactory->create();
          // URL is checked to be internal in $this->_redirect->success()
          $resultRedirect->setUrl($this->_redirect->success($redirectUrl));
          return $resultRedirect;
          else
          $resultRedirect = $this->resultRedirectFactory->create();
          $resultRedirect->setPath('');
          return $resultRedirect;

          catch (EmailNotConfirmedException $e)
          $value = $this->customerUrl->getEmailConfirmationUrl($login['username']);
          $message = __(
          'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
          $value
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (UserLockedException $e)
          $message = __(
          'You did not sign in correctly or your account is temporarily disabled.'
          );
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (AuthenticationException $e)
          $message = __('You did not sign in correctly or your account is temporarily disabled.');
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (LocalizedException $e)
          $message = $e->getMessage();
          $this->messageManager->addError($message);
          $this->session->setUsername($login['username']);
          catch (Exception $e)
          // PA DSS violation: throwing or logging an exception here can disclose customer password
          $this->messageManager->addError(
          __('An unspecified error occurred. Please contact us for assistance.')
          );

          else
          $this->messageManager->addError(__('A login and a password are required.'));



          return $this->accountRedirect->getRedirect();




          I hope this will help







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 6 mins ago

























          answered 11 mins ago









          Muhammad HashamMuhammad Hasham

          2,7932831




          2,7932831












          • on checkout page, how can i change input type email to text ? so user can add their mobile number.

            – Charvi Parikh
            7 mins ago

















          • on checkout page, how can i change input type email to text ? so user can add their mobile number.

            – Charvi Parikh
            7 mins ago
















          on checkout page, how can i change input type email to text ? so user can add their mobile number.

          – Charvi Parikh
          7 mins ago





          on checkout page, how can i change input type email to text ? so user can add their mobile number.

          – Charvi Parikh
          7 mins ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269815%2fmagento-2-checkout-login-with-mobile-number-or-email%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          Magento 2 disable Secret Key on URL's from terminal The Next CEO of Stack OverflowMagento 2 Shortcut/GUI tool to perform commandline tasks for windowsIn menu add configuration linkMagento oAuth : Generating access token and access secretMagento 2 security key issue in Third-Party API redirect URIPublic actions in admin controllersHow to Disable Cache in Custom WidgetURL Key not changing in Magento 2Product URL Key gets deleted when importing custom options - Magento 2Problem with reindex terminalMagento 2 - bin/magento Commands not working in Cpanel Terminal

          Aasi (pallopeli) Navigointivalikko