覆盖Laravel 7中的默认身份验证路由

时间:2020-05-22 20:21:53

标签: php laravel

我需要自定义Auth::routes();的路由,找不到它们,请尝试在Router.php中搜索

 Vendor\laravel\framework\src\Illuminate\Routing\Router.php

但是我没有找到它们!

3 个答案:

答案 0 :(得分:6)

在Laravel-7的Auth :: routes();中使用vendor/laravel/ui/src/AuthRouteMethods.php

中定义的函数auth()

您可以复制此功能的内容并将其直接粘贴到web.php文件中,然后根据需要进行更新。

public function auth()
{
    // Authentication Routes...
    $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
    $this->post('login', 'Auth\LoginController@login');
    $this->post('logout', 'Auth\LoginController@logout')->name('logout');

    // Registration Routes...
    $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
    $this->post('register', 'Auth\RegisterController@register');

    // Password Reset Routes...
    $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
    $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
    $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
    $this->post('password/reset', 'Auth\ResetPasswordController@reset');
}

答案 1 :(得分:0)

php artisan route:list

请尝试使用此工匠命令。

答案 2 :(得分:0)

不需要覆盖Dog。将其从路由文件中删除,然后在其中放置您自己的自定义路由。 Auth Facade具有route()方法,它从Router类调用auth()方法来注册Auth路由。