ZF-Commons / ZfcUser

A generic user registration and authentication module for ZF2. Supports Zend\Db and Doctrine2. (Formerly EdpUser)
BSD 3-Clause "New" or "Revised" License
497 stars 343 forks source link

Redirect parameter #617

Open Avatar4eg opened 8 years ago

Avatar4eg commented 8 years ago

Hey. I have an issue when trying to use "use_redirect_parameter_if_present" on 1.4.x. First: In form redirect parameter not exist:

<?php echo $this->partial('_form.phtml', ['form' => $form]); ?>

Seems to be:

<?php echo $this->partial('_form.phtml', ['form' => $form, 'redirect' => $redirect]); ?>

Second: Routes like "admin/screen/view/1" not allowed in routeExists() function of RedirectCallback. "admin/screen" is okey.

For generating redirect parameter i use:

$eventManager->attach(MvcEvent::EVENT_ROUTE, function($e) use ($serviceManager) {
            $routeMatch = $e->getRouteMatch();

            $auth = $serviceManager->get('zfcuser_auth_service');
            if (!$auth->hasIdentity() && $routeMatch->getMatchedRouteName() != 'admin/auth/login'
                && $routeMatch->getMatchedRouteName() != 'zfcuser/login') {
                $redirect = $e->getRouter()->assemble(
                    $routeMatch->getParams(),
                    ['name' => $routeMatch->getMatchedRouteName(),]
                );

                $response = $e->getResponse();
                $response->getHeaders()->addHeaderLine(
                    'Location',
                    $e->getRouter()->assemble(
                        [],
                        [
                            'name' => 'zfcuser/login',
                            'query' => ['redirect' => $redirect]
                        ]
                    )
                );
                $response->setStatusCode(302);
                return $response;
            }
        });
nclundsten commented 8 years ago

missing redirect param came from 0d1c7bab, this could be fixed immediately, the other part hopefully is fixed with 2.0.