在cakephp中多次登录3

时间:2018-04-25 07:49:57

标签: authentication cakephp-3.0 cakephp-3.x cakephp-3.4

我必须在单独的登录屏幕上创建用户供应商类型。在Appcontroller下我添加了

public function beforeFilter(Event $event){

    $this->Auth->allow(['login', 'logout','vendor_login','vendor_logout']);

}

    $this->loadComponent('Auth', [
            'authorize' => [
                    'Acl.Actions' => ['actionPath' => 'controllers/']
            ],
            'loginAction' => [
                    'plugin' => false,
                    'controller' => 'Users',
                    'action' => 'login'
            ],
            'loginRedirect' => [
                    'plugin' => false,
                    'controller' => 'Pages',
                    'action' => 'display',
                    'home'
            ],
            'logoutRedirect' => [
                    'plugin' => false,
                    'controller' => 'Users',
                    'action' => 'login'
            ],  
            'vendorLoginAction' => [
                    'plugin' => false,
                    'controller' => 'Users',
                    'action' => 'vendorLogin'
            ],
            'vendorLoginRedirect' => [
                    'plugin' => false,
                    'controller' => 'BoldNumberRequest',
                    'action' => 'index',
                    'home'
            ],
            'vendorLogoutRedirect' => [
                    'plugin' => false,
                    'controller' => 'Users',
                    'action' => 'vendorLogout'
            ],
            'unauthorizedRedirect' => [
                    'controller' => 'Pages',
                    'action' => 'display',
                    'prefix' => false
            ],
            'authError' => 'You are not authorized to access that location.',
            'flash' => [
                    'element' => 'error'
            ]
    ]);

已为用户创建vendorLogin函数和vendor_login.ctp。 在route.php文件中,我添加了

Router::scope('/', function (RouteBuilder $vendorroutes) {
    $vendorroutes->setExtensions(['json', 'xml','pdf']);
    $vendorroutes->connect('/', ['controller' => 'Users', 'action' => 'vendorLogin']);
    $vendorroutes->connect('/boldnumberrequest/*', ['controller' => 'BoldNumberRequest', 'action' => 'index-vendor']);

    $routes->fallbacks(DashedRoute::class);
});
Router::prefix('vendorLogin', function ($vendorroutes) {
    $vendorroutes->fallbacks('DashedRoute');
});

供应商登录屏幕即将到来但登录后应重定向到  http://localhost/polymer_erp/bold-number-request/index但它重定向到http://localhost/polymer_erp/pages/home,这是其他登录用户的默认设置。 此过程是否正确,如何在登录后更改默认重定向。?

0 个答案:

没有答案