简体   繁体   中英

cakephp 3 multiple Auth login

i have 3 different types of users : website users,Sponsors and Admin, each one associated to a table. I can't merge the tables since they have different fields.

I would like to use 3 different auth, how can I do?

Controller name 1. UsersController 2. SponsorsController 3. AdminsSController

please can you sent to me sample code or guide lines how can do in cakephp 3.x.

Thanks for your help!

There are many ways to achieve it. You can simply create admin_panel and sponsors_panel folders under your /src/Controllers folder.

Then create related controller in those folder and define routing in /confing/routes.php as per your website for eg

Router::prefix('admin_panel', function ($routes) {
    $routes->connect('/', ['controller' => 'Admin', 'action' => 'login']);
    $routes->fallbacks('DashedRoute');
});

Router::prefix('sponsors_panel', function ($routes) {

        $routes->connect('/', ['controller' => 'Sponsors', 'action' => 'login']);
        $routes->fallbacks('DashedRoute');
    });

Then you can access your login panels using

http://www.example.com/sponsors_panel

http://www.example.com/admin_panel

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM