Sylius / Sylius-Sandbox

[DEPRACATED] Sylius sandbox application, playground and testing place for Sylius and Symfony2 beginners.
Sylius.org
MIT License
76 stars 24 forks source link

Step with name "security" does not exist, when login with existed user on checkout #81

Closed Evgenas closed 11 years ago

Evgenas commented 11 years ago

got error:
Step with name "security" does not exist

when logged with already registered user on checkout stage

Also i have checked on your live demo and getting same error

I have discover and see that you fave disabling security step on CheckoutProccessScenario.php line 24:

    if (!is_object($this->container->get('security.context')->getToken()->getUser())) {
        $builder->add('security', new Step\SecurityStep());
    }

but it looks like logged user is staying on security step, that makes error

My quick solution was:

CheckoutProccessScenario.php line 24:

   // if (!is_object($this->container->get('security.context')->getToken()->getUser())) {
        $builder->add('security', new Step\SecurityStep());
  //  }

line 32: ->setDisplayRoute('sylius_sandbox_checkout_dispaly') change to ->setDisplayRoute('sylius_sandbox_checkout_forward')

cause we have same template loading at display and forward action and registration step redirect fine to next step

Then added follow lines to SecurityStep.php line 37:

public function forwardAction(ProcessContextInterface $context)
{
    $this->overrideSecurityTargetPath();

    // added by me to lets go to next step if user already logged
    if (is_object($this->container->get('security.context')->getToken()->getUser()) ) {
       $context->complete(); 
    }
   // end 

As said it was just quick solution, so may be you will fix it properly

pjedrzejewski commented 11 years ago

I can confirm, I noticed that recently. I'll think about proper solution, I think that adding this "already logged user -> complete" thing should solve this, without swapping the routes. I'll check. Thanks for reporting!

pjedrzejewski commented 11 years ago

This should be fixed now. :) Thanks again for noticing.