简体   繁体   English

Laravel-我找不到身份验证中间件

[英]Laravel - I can't find the Authenticate Middleware

I'm new to Laravel and as said in the title I can't find the Authenticate Middleware. 我是Laravel的新手,正如标题所述,我找不到身份验证中间件。 I know it should be in app/http/middleware/Authenticate, as it was in previous projects, but it's not there. 我知道它应该在app / http / middleware / Authenticate中,就像以前的项目一样,但是不存在。 The ones that are there are: Encrypt.. , RedirectifAuth.. and VerifyCsrf... I hope you can help me locate it. 那里有:加密..,RedirectifAuth ..和VerifyCsrf ...希望您能帮助我找到它。

Laravel 5.2 Laravel 5.2

'app/http/middleware/Authenticate.php' 'app / http / middleware / Authenticate.php'

Laravel 5.3 Laravel 5.3

'app/exceptions/handler.php' 'app / exceptions / handler.php'

Unless you have a solid understanding of what you're doing it is not recommended that you move or overwrite files within the vendor folder. 除非您对正在执行的操作有深入的了解, 否则建议不要移动或覆盖供应商文件夹中的文件。

That being said, you CAN overwrite the Authenticate.php file and just modify your Kernel.php file: 话虽如此,您可以覆盖Authenticate.php文件,而只需修改Kernel.php文件即可:

/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,  <--Change this Directory
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    ...
];

To: 至:

/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class, <--- There you go
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    ...
];

Be sure to copy and paste the code from the Authenticate file in the vendor folder into the Authenticate file in your app\\http\\middleware directory to resume the same functionality. 确保将代码从供应商文件夹中的Authenticate文件复制并粘贴到app \\ http \\ middleware目录中的Authenticate文件中,以恢复相同的功能。

Again it's not recommended you do this unless you have a solid understanding of what you're doing and how it all works. 同样,不建议您执行此操作,除非您对正在执行的操作及其全部工作方式有深入的了解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM