两个不同Auth验证失败之后为什么会跳转到同一个login界面呢

在项目里设置了两个Auth验证,分别是front和admin
//中间件AdminAuthenticateMiddleware

public function handle($request, Closure $next)
{
    if (!Auth::guard('admin')->check()) {
        return redirect('/admin/login');
    }

    return $next($request);
}

//中间件FrontAuthenticateMiddleware

public function handle($request, Closure $next)
{
    if (!Auth::guard('front')->check()) {
        return redirect('/front/login');
    }

    return $next($request);
}

}
也在kernel文件中进行注册了```php

class Kernel extends HttpKernel
{

protected $middleware = [

    \App\Http\Middleware\TrustProxies::class,
    \Illuminate\Http\Middleware\HandleCors::class,
    \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
    \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
    \App\Http\Middleware\TrimStrings::class,
    \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,

];

protected $middlewareGroups = [
    'web' => [

        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
        'throttle:api',
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],
];

protected $routeMiddleware = [
    'auth.admin' => AdminAuthenticateMiddleware::class,
    'auth.front' => FrontAuthenticateMiddleware::class,

    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
    'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
    'signed' => \App\Http\Middleware\ValidateSignature::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

这是路由的设置

Route::view('front/login', 'front.login')->name('front.login');
Route::post('/front/login', [UserController::class, 'doLogin']);
Route::view('/admin/login', 'admin.login')->name('admin.login');
Route::post('/admin/login', [ManagerController::class, 'doLogin']);


Route::prefix('/front')->middleware('auth:front')->group(function (){

});

Route::prefix('admin')->middleware('auth:admin')->group(function (){

});

但是会报错,会显示Route [login] not defined错误,如果把name里面login前面的admin和front去掉的话页面会显示,但是两个Auth验证失败时都会跳转到页面admin.login上。
是因为什么呢??

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
Mutoulee
最佳答案

有没有可能是App\Http\Middleware\Authenticate.php在捣鬼 :joy:

4周前 评论
Mutoulee (作者) 4周前
yuantao (楼主) 4周前
yuantao (楼主) 4周前
yuantao (楼主) 4周前
Mutoulee (作者) 4周前
讨论数量: 6
Mutoulee

有没有可能是App\Http\Middleware\Authenticate.php在捣鬼 :joy:

4周前 评论
Mutoulee (作者) 4周前
yuantao (楼主) 4周前
yuantao (楼主) 4周前
yuantao (楼主) 4周前
Mutoulee (作者) 4周前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!