Skip to content

fix: multiple guard select#558

Closed
AminulBD wants to merge 1 commit intolaravel:4.xfrom
AminulBD:4.x
Closed

fix: multiple guard select#558
AminulBD wants to merge 1 commit intolaravel:4.xfrom
AminulBD:4.x

Conversation

@AminulBD
Copy link

@AminulBD AminulBD commented Feb 7, 2025

When we've guards like this:

// config/auth.php
'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],
        'api' => [
            'driver' => 'sanctum',
            'provider' => 'users',
        ],
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
        'admin-api' => [
            'driver' => 'sanctum',
            'provider' => 'admins',
        ],
    ],

and sanctum config:

// config/sanctum.php
'guard' => ['web', 'admin'],

and using middleware like this:

Route::group(['middleware' => 'auth:web,api'], ...);
Route::group(['middleware' => 'auth:admin,admin-api'], ...);

It was always pick the default web guard, and never going to correct and use the admin or admin-api guard on the scope.

So, I patched this to fix that issue and use correct guard always.

@taylorotwell
Copy link
Member

I am closing this pull request because it lacks sufficient explanation, tests, or both. It is difficult for us to merge pull requests without these things because the change may introduce breaking changes to the framework.

Feel free to re-submit your change with a thorough explanation of the feature and tests - integration tests are preferred over unit tests. Please include it's benefit to end users; the reasons it does not break any existing features; how it makes building web applications easier, etc.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants