mardi 17 mars 2020

Is there a way to assign a custom guard to a specific user role or user id in Laravel 5.7?

I am new to Laravel and working on a project which is using 5.7 version.I want to implement the concept of custom guard. I have created 3 guards along with their provider (which is same for all 3 guards) inside config/auth.php. Now I want to use this 'masteradmin' guard only for users with lets say role_id = 14? Can this be achieved, if yes then where should I define the relation between masteradmin guard and users with role_id = 14?

    'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'user',
    ],

    'masteradmin' => [
        'driver' => 'session',
        'provider' => 'user',
    ],

    'salesaccess' => [
        'driver' => 'session',
        'provider' => 'user',
    ],

    'ordermanager' => [
        'driver' => 'session',
        'provider' => 'user',
    ],

    'api' => [
        'driver' => 'token',
        'provider' => 'user',
    ],
],

'providers' => [
    'user' => [
        'driver' => 'database',
        'table' => 'user',
    ],
],


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire