What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi Team, I'm trying to enable users to log in with a mobile number on YVES, for t
Hi Team,
I'm trying to enable users to log in with a mobile number on YVES, for that I have already updated the registration form and now the mobile number is getting stored in the DB. Thanks, @UNGMX0012 for helping me out.
Now to override the login module I have extended the tryAuthorizeCustomerByEmailAndPassword
From here \vendor\spryker\customer\src\Spryker\Zed\Customer\Business\Customer\Customer.php
At \src\Pyz\Zed\Customer\Business\Customer\Customer.php
And CustomerQueryContainer from here \vendor\spryker\customer\src\Spryker\Zed\Customer\Persistence\CustomerQueryContainer.php
At \src\Pyz\Zed\Customer\Persistence\CustomerQueryContainer.php
And I have also extended the customerBusinessFactory.
But it's not working.
Can you please check and let me know what I have done wrong here.
Thanks
Comments
-
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Hey, “But it’s not working.” does not really give a lot of information what fails 😕
Have you debugged with xdebug? - Is the phone-number and pw properly received by your overriden files?
0 -
what I did is I have added die() in the vendor file as well, then also its not failing, so I'm not sure whether its a correct method or not
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Please setup xdebug with your IDE to test and trace properly
0 -
Here is the code for customer.php
<?php /** * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ namespace Pyz\Zed\Customer\Business\Customer; use Spryker\Zed\Customer\Business\Customer\Customer as SprykerCustomer; use Generated\Shared\Transfer\CustomerTransfer; class Customer extends SprykerCustomer { /** * @var \Spryker\Zed\Customer\Persistence\CustomerQueryContainerInterface */ protected $queryContainer; /** * @param \Generated\Shared\Transfer\CustomerTransfer $customerTransfer * * @return bool */ public function tryAuthorizeCustomerByEmailAndPassword(CustomerTransfer $customerTransfer) { $customerEntity = $this->queryContainer->queryCustomerByEmailOrMobileNumber($customerTransfer) ->findOne(); if (!$customerEntity) { return false; } if (!parent::isValidPassword($customerEntity->getPassword(), $customerTransfer->getPassword())) { return false; } if ($this->customerConfig->isDoubleOptInEnabled() && !$customerEntity->getRegistered()) { return false; } return true; } }
CustomerQueryContainer
<?php /** * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ namespace Pyz\Zed\Customer\Persistence; use Spryker\Zed\Customer\Persistence\CustomerQueryContainer as SprykerCustomerQueryContainer; /** * @method \Spryker\Zed\Customer\Persistence\CustomerPersistenceFactory getFactory() */ class CustomerQueryContainer extends SprykerCustomerQueryContainer { /** * @api * * @inheritDoc */ public function queryCustomerByEmailOrMobileNumber($customer) { $query = parent::queryCustomers(); $query->filterByEmail($customer->getEmail()) ->_or() ->filterByMobileNumber($customer->getEmail()); return $query; } }
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Have you also updated the BusinessFactory to use your new file (Customer)?
0 -
I did that when I'm running it in debug more then also its not stopping at breakpoints which I have added
0 -
Yes Here is that file
<?php /** * Copyright © 2016-present Spryker Systems GmbH. All rights reserved. * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. */ namespace Pyz\Zed\Customer\Business; use Spryker\Zed\Customer\Business\CustomerBusinessFactory as SprykerCustomerBusinessFactory; use Pyz\Zed\Customer\Business\Customer\Customer; /** * @method \Spryker\Zed\Customer\CustomerConfig getConfig() * @method \Pyz\Zed\Customer\Persistence\CustomerQueryContainer getQueryContainer() * @method \Spryker\Zed\Customer\Persistence\CustomerEntityManagerInterface getEntityManager() * @method \Spryker\Zed\Customer\Persistence\CustomerRepositoryInterface getRepository() */ class CustomerBusinessFactory extends SprykerCustomerBusinessFactory { /** * @return \Spryker\Zed\Customer\Business\Customer\CustomerInterface */ public function createCustomer() { $config = $this->getConfig(); $customer = new Customer( $this->getQueryContainer(), $this->createCustomerReferenceGenerator(), $config, $this->createEmailValidator(), $this->getMailFacade(), $this->getLocaleQueryContainer(), $this->getLocaleFacade(), $this->createCustomerExpander(), $this->createCustomerPasswordPolicyValidator(), $this->getPostCustomerRegistrationPlugins(), ); return $customer; } }
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
and that one is called?
0 -
Yes when I add died here in this mrthod that time login request failed
0 -
Did u delete class resolver cache as well?
0 -
Yes I have used this command for that
docker/sdk console cache:class-resolver:build
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
i foggy remember that this method is not directly used by yves login.
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
Have a look at
vendor/spryker-shop/customer-page/src/SprykerShop/Yves/CustomerPage/Plugin/Provider/CustomerUserProvider.php
0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
loadUserByUsername()
is a method used by symfony security module - your username is the phone number0 -
fsmeier Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,084 ⚖️ - Guardians (admin)
set a breakpoint there and check if you receive the phone number there. And from that point you can start to follow the methods
0 -
Sure thanks for the reply, will check that
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random