In a next instalment in the orinoco-river-zf2-project (alternative skeleton for Zend Framework II) a few notes on the zfcUser module already installed earlier.

If the form validation fails or the authentication fails this is what happens next:

const ROUTE_LOGIN = 'zfcuser/login';

$this->flashMessenger()
->setNamespace($this->loginNamespace)
->addMessage($this->failedLoginMessage);
return $this->redirect()
->toUrl($this->url()
->fromRoute(static::ROUTE_LOGIN) . ($redirect ? '?redirect=' . rawurlencode($redirect) : ''));

If you have the layout for the form diverted via a custom route this is a problem.

The alternative is to retrieve the route already defined in the shared configuration file:

$route = $this->options->getLogoutRedirectRoute();
return $this->redirect()
->toUrl($this->url()
->fromRoute($route) . ($redirect ? '?redirect=' . rawurlencode($redirect) : ''));

This requires modification of an existing external library. Luckily this library can be forked on github and these are the steps to take:
* Fork ZfcUser
* create a branch called “bugfix”
* push changes to github
* adjust the composer.json file as:

"repositories": [{
    "type": "vcs",
    "url": "https://github.com/your-repos-name/ZfcUser"
     }],
    
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "*",
        "zf-commons/zfc-user": "dev-bugfix as 1.0.0"
       
    },

In this file you create a repository of type vcs (version control system) and the url is the url specified by github for this project. You still require zf-commons/zfc-user but you also create an alias of release 1.0.0. (1.* won’t do here because the release has to be precise) called dev-bugfix. Do not make the mistake of creating a branch called “dev-bugfix”.

On deploying “composer update” the bugfix will be selected rather than the main branch

 Updating zf-commons/zfc-user (dev-master 066ecc4 => dev-bugfix a5a5b9c)
 Checking out a5a5b9c8b36d71e2d294ba74b6e53387584c8271

Also make sure to capture the namespace “zfcuser-login-form” in rendering the flash messenger. See the latests commits here.

Advertisements