| Q | A
| ---------------- | -----
| Bug report? | yes
| Feature request? | no
| BC Break report? | no
| RFC? | no
| Sylius version | master
i have this erro:
The identifier id is missing for a query of Sylius\Component\Core\Model\Customer
basically my uri is /en_US/account/dashboard?id=number
Istead it must be just home ( /en_US) on first redirect.
how to fix it?
from
sylius_shop_register:
path: /register
methods: [GET, POST]
defaults:
_controller: sylius.controller.customer:createAction
_sylius:
template: "@SyliusShop/register.html.twig"
form: Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
event: register
redirect:
route: sylius_shop_account_dashboard
to
sylius_shop_register:
path: /register
methods: [GET, POST]
defaults:
_controller: sylius.controller.customer:createAction
_sylius:
template: "@SyliusShop/register.html.twig"
form: Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
event: register
redirect:
route: sylius_shop_homepage
same error on verify.
Same type of fix.
It seems like https://github.com/Sylius/Sylius/blob/master/app/config/security.yml#L102 doesn't work?
I can confirm this bug with Sylius 1.0.4
The customer is not authenticated, so the service sylius.context.customer cannot find the newly registred customer.
EDIT:
In fact, the shop firewall was missing for me. Maybe for you @Bonobomagno it's the same problem
parameters:
sylius.security.shop_regex: ""
security:
firewalls:
shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
pattern: "%sylius.security.shop_regex%"
form_login:
success_handler: sylius.authentication.success_handler
failure_handler: sylius.authentication.failure_handler
provider: sylius_shop_user_provider
login_path: sylius_shop_login
check_path: sylius_shop_login_check
failure_path: sylius_shop_login
default_target_path: sylius_shop_homepage
use_forward: false
use_referer: true
remember_me:
secret: "%secret%"
name: APP_REMEMBER_ME
lifetime: 31536000
remember_me_parameter: _remember_me
logout:
path: sylius_shop_logout
target: sylius_shop_login
anonymous: true
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.
This is still happening on 1.2.3 fresh install
I've been debugging this this morning.
I could be wrong, but would appricate a logic check.
After creating a user, you get directed to https://storename.com/account/dashboard?id=2
One of the first points outside the kernel is showAction in vendor\sylius\sylius\src\Sylius\Bundle\ResourceBundle\Controller\ResourceController.php. It tries to generate the configuration via a configuration factory. At this point in execution metadata is a properly instanciated object:
and request is a Symfony\Component\HttpFoundation\Request class wherein query->parameters is an array where the only element is id = 2. Thus, in theory, the factory should have everything it needs.
Going into vendor\sylius\sylius\src\Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactory.php in the create method it merges the default params (which id is not in (these values come from vendor\sylius\sylius\src\Sylius\Bundle\ResourceBundle\DependencyInjection\Configuration.php)) and any api params, which are not present in this instance. Thus id is never injected into $parameters, which means it isn't in the generated configuration object, which in turn (inside findOr404 back in the resource controller, which then loads get in the SingleResourceProvider) eventually tries to run return $repository->$method(...$arguments) where $repository is the correct CustomerRepository, $method is the correct string of "find" but $arguments is null from the above.

Small note: I shopped in the watch as it was obscured, hence it being in an odd spot
so the question is, is the configuration factory wrong to not look in the request query params, or is this really a security config issue?
Short term fix is to redirect the user to the login rather than the dashboard:
Insert the follwoing into app/config/routing.yml
sylius_shop_register:
path: /register
methods: [GET, POST]
defaults:
_controller: sylius.controller.customer:createAction
_sylius:
template: "@SyliusShop/register.html.twig"
form: Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
event: register
redirect:
route: sylius_shop_login
flash: sylius.customer.register
sylius_shop_user_verification:
path: /verify/{token}
methods: [GET]
defaults:
_controller: sylius.controller.shop_user:verifyAction
_sylius:
redirect: sylius_shop_login
Short term fix is to redirect the user to the login rather than the dashboard:
Insert the follwoing into app/config/routing.yml
Works for me, i confirm that the problem was the redirection in the dashboard.
Sylius 1.3.1
Nice fix, problem is still occurring with current version of sylius
The identifier id is missing for a query of App\Entity\Customer\Customer
For sylius 1.8.1
Most helpful comment
Short term fix is to redirect the user to the login rather than the dashboard:
Insert the follwoing into app/config/routing.yml