简体   繁体   中英

Multiple authentication table in Laravel 5.1

I have two type user. And two table for them.
1. technicians
2. requesters
Is there any way to Multiple authentication in laravel 5.1?
I see and read this post.
Laravel 5.1 multiple authentication
but I am not separate users by group_id in users table.
I want save user and password in each table. technicians user , pass save in technician table and requsters too.
is there any way? by the way each table has special roules

You can install this package: https://github.com/Kbwebs/MultiAuth

Please read the documentation.

In this package you can create multiple auth. This will override the laravel's auth system.

For example you want to create auth for user and admin.

In the config/auth.php you define the 2 auth:

'multi-auth' => [
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class
    ],
    'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class
    ]
]

Also your auth syntax will change, please see image below that will show you camparison in syntax, how to login a user and admin versus the Default laravel auth syntax:

在此处输入图片说明

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