Disable default zfcUser routes?

北城余情 提交于 2020-01-04 06:46:08

问题


I'm using zfcUser and I was wondering if its possible to disable the default routes, such as zfcUser/login, zfcUser/register, etc because I do not want to expose them.

I looked at the zfcuser.global.php but there seems to be no such option?

Thanks


回答1:


You can simply override the configuration by setting a null controller or an unmatchable routing configuration.

Solution 1: override the zfcuser controller invokable:

// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php

return array(
    'controllers' => array(
        'invokables' => array(
            'zfcuser' => null,
        ),
    ),
);

Solution 2: overriding routing configuration by using your own route config (hacky, discouraged):

// YourApp\Module#getConfig() or config/autoload/zfcuser.override.global.php

return array(
    'router' => array(
        'routes' => array(
            'zfcuser' => array(
                // changing to hostname route - using an unreachable hostname
                'type' => 'Hostname',
                // minimum possible priority - all other routes come first.
                'priority' => ~PHP_INT_MAX,
                'options' => array(
                    // foo.bar does not exist - never matched
                    'route' => 'foo.bar',
                    'defaults' => array(
                        'controller' => null,
                        'action' => 'index',
                    ),
                ),

                // optional - just if you want to override single child routes:
                'child_routes' => array(
                    'login' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'authenticate' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'logout' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'register' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'changepassword' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                    'changeemail' => array(
                        'options' => array(
                            'defaults' => array(
                                'controller' => null,
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
);


来源:https://stackoverflow.com/questions/15494787/disable-default-zfcuser-routes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!