0

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

3
  • why not have only one table for users then a user can belong to technicians or requesters, then use Laravel hasOne relationship or belongsTo, no need for multiple users , not the best Commented Dec 17, 2015 at 7:09
  • I think what you are looking for is role based authentication. It's not a good idea to save different types of users to different tables. You could Entrust for laravel. Commented Dec 17, 2015 at 7:12
  • thanks, If I use one table, requsters change group_id and become to technicians. if requester is hacker and bypass the group_id Commented Dec 17, 2015 at 7:18

1 Answer 1

1

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:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.