日期:2017-03-01 阅读:1989
dmandwp系统 - wordpress系统和DM系统区块建站>>
https://laravel-china.org/docs/5.4/authentication
Laravel 通过运行如下命令可快速生成认证所需要的路由和视图:
配置文件位于 config/auth.php
---------------
1、php artisan make:auth
2、然后可以查看路由: 
php artisan route:list 
3、如果之前没有做数据库迁移的话,需要: php artisan migrate
用来生成user表
如果迁移报错,请看>
-----------------
在routes/web.php会多出:
Auth::routes();     ------ vendor\laravel\framework\src\Illuminate\Routing\Router.php
Route::get('/home', 'HomeController@index');
------------
vendor\laravel\framework\src\Illuminate\Routing\Router.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');
    }
    
--------------------
中间件,可以查看auth和guest对应的代码。
protected $routeMiddleware = [
    'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
------------------
RegisterController控制器里:
 这些控制器使用了 trait 来包含所需要的方法,对于大多数的应用程序而言,你并不需要修改这些控制器。
 
use RegistersUsers;
在vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php
有trait RegistersUsers
和
showRegistrationForm 和 register等方法
----------------
具体请看视频教程。