Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routes defined in UserController as constants ROUTE_ should be configurable #684

Open
MadCat34 opened this issue Dec 28, 2018 · 2 comments

Comments

@MadCat34
Copy link

Some routes are defined as constants in UserController

const ROUTE_CHANGEPASSWD = 'zfcuser/changepassword';
const ROUTE_LOGIN        = 'zfcuser/login';
const ROUTE_REGISTER     = 'zfcuser/register';
const ROUTE_CHANGEEMAIL  = 'zfcuser/changeemail';

In order to change these routes, we should extend UserController.

It should be configurable with the moduleOptions.

I have overwrited routes to use
dashboard/user
dashboard/user/login
[...]
using UserController and action from ZfcUser.

If I go to /dashboard/user, and if I'm not logged, UserController redirect me to ROUTE_LOGIN (/user/login) instead of /dashboard/user/login

IMO, Configurable options is easier than extend UserController

What is your opinion about this ?

@jroedel
Copy link

jroedel commented Dec 29, 2018

If I'm not mistaken you should be able to overwrite the path of those routes in configuration without changing the name of the routes.
For example:

return [
  'router' => [
    'zfcuser' => [
      'path' => 'dashboard/user',
    ],
  ],
];

I'm not at my computer right now to test it, but I think that should work.

@MadCat34
Copy link
Author

This is what I have done.
But going to dashboard/user with unregistered user redirect to user/login.

The problem is the use of constants (see UserController::indexAction)

public function indexAction()
{
    if (!$this->zfcUserAuthentication()->hasIdentity()) {
        return $this->redirect()->toRoute(static::ROUTE_LOGIN);
    }
    return new ViewModel();
}

If you want to redirect to a custom route, actually you have to extends UserController...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants